﻿function RCoordinate(x, y) {
    if (x && (!isNaN(x))) {
        this.x = this.get_dealed_x(x);
    }
    if (y && (!isNaN(y))) {
        this.y = this.get_dealed_y(y);
    }
    this.get_dealed_x = function(x) {
        var multiple = this.get_multiple(Math.PI * EARTH_RADIUS, x);
        var mod = x % (Math.PI * EARTH_RADIUS);
        var position_value = multiple % 2;
        switch (position) {
            case 0:
                return mod;
            case 1:
                return (Math.PI * EARTH_RADIUS - mod) * -1;
            default:
                return 0;
        }
    }
    this.get_dealed_y = function(y) {
        var multiple = this.get_multiple(EARTH_RADIUS, y);
        var mod = y % EARTH_RADIUS;
        var position_value = multiple % 4;
        switch (position) {
            case 0:
                return mod;
            case 1:
                return EARTH_RADIUS - mod;
            case 2:
                return mod * -1;
            case 3:
                return (EARTH_RADIUS - mod) * -1;
            default:
                return 0;
        }
    }
    this.get_multiple = function(NoSource, No) {
        var multiple = No / noSource;
        if (multiple > multiple.toFixed(0)) {
            return multiple.toFixed(0) - 1;
        }
        return multiple.toFixed(0);
    }
    this.fromLatLng = function(latlng, type) {
        if (type.length > 0 && type != "default") {
            return;
        }
        this.x = (latlng.lng * Math.PI / 180) * EARTH_RADIUS;
        this.y = Math.sin(latlng.lat * Math.PI / 180) * EARTH_RADIUS;
    }
    this.toLatLng = function(type) {
        if (type.length > 0 && type != "default") {
            return null;
        }
        var latlng = new RLatLng();
        latlng.lng = (180 * this.x) / (EARTH_RADIUS * Math.PI);
        latlng.lat = Math.asin(this.y / EARTH_RADIUS) * 180 / Math.PI;
        return latlng;
    }
    this.getX = function() {
        return this.x;
    }
    this.getY = function() {
        return this.y;
    }
    this.setX = function(x) {
        this.x = get_dealed_x(x);
    }
    this.setY = function(y) {
        this.y = get_dealed_y(y);
    }
    this.toString = function() {
        return "RCoordinate";
    }
}
function RDiv(left, top, width, height) {
    this.div = document.createElement("Div");
    this.style = this.div.style;
    this.div.align = 'left';
    this.div.unselectable = 'on';
    this.style.position = "absolute";
    this.style.fontSize = 12;
    if (left) {
        this.style.left = left;
    } else {
        this.style.left = 0;
    }
    if (top) {
        this.style.top = top;
    } else {
        this.style.top = 0;
    }
    if (width) {
        this.style.width = width;
    }
    if (height) {
        this.style.height = height;
    }
    this.style.visibility = 'inherit';
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return 'RDiv';
    }
}
function RXmlParser() {
    this.ObjectToXml = function(obj, xmlstr, bEncryptValues) {
        var docXml = new RXMLDocument();
        Xml = docXml.get();
        var node = this.ObjectToNode(obj, xmlstr, bEncryptValues);
        return Xml.appendChild(node);
    }
    this.ObjectToNode = function(obj, xmlstr, bEncryptValues) {
        var docXml = new RXMLDocument();
        Xml = docXml.get();
        var node;
        if (!isNaN(xmlstr)) {
            node = Xml.createElement("RArray");
        } else {
            node = Xml.createElement(xmlstr);
        }
        for (var objChild in obj) {
            if (typeof (obj[objChild]) == "function") {
                continue;
            }
            if (typeof (obj[objChild]) == "object") {
                var temXml = this.ObjectToNode(obj[objChild], objChild, bEncryptValues);
                node.appendChild(temXml);
                continue;
            }
            var childNode;
            if (!isNaN(objChild)) {
                childNode = Xml.createElement("RArray");
            } else {
                childNode = Xml.createElement(objChild);
            }
            childNode.text = obj[objChild];
            node.appendChild(childNode);
        }
        return node;
    }
    this.XMLtoObject = function(docXml) {
        var obj = new Object();
        if (docXml) {
            for (var index = 0; index < docXml.childNodes.length; index++) {
                if (docXml.childNodes[index].nodeType == 1 || docXml.childNodes[index].nodeType == 9) {
                    this.ParseXML(docXml.childNodes[index], obj);
                }
            }
        }
        return obj;
    }
    this.ParseXML = function(docXml, objTarget) {
        if (docXml.attributes) {
            for (var i = 0; i < docXml.attributes.length; i++) {
                objTarget[docXml.attributes[i].nodeName] = docXml.attributes[i].nodeValue;
            }
        }
        var childs = docXml.childNodes;
        if (childs.length == 0) {
            objTarget.nodeValue = "";
        }
        for (i = 0; i < childs.length; i++) {
            if (childs[i].childNodes.length == 0 && childs[i].nodeType == 3) {
                objTarget.nodeValue = (childs[i].text || childs[i].textContent);
            } else {
                if (typeof (objTarget[childs[i].nodeName]) == 'undefined') {
                    objTarget[childs[i].nodeName] = new Object();
                    objTarget[childs[i].nodeName].Rtype = "obj";
                    this.ParseXML(childs[i], objTarget[childs[i].nodeName]);
                } else if (objTarget[childs[i].nodeName].Rtype == "obj") {
                    var objTemp = objTarget[childs[i].nodeName];
                    objTarget[childs[i].nodeName] = new Array();
                    objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length] = objTemp;
                    objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length] = new Object;
                    this.ParseXML(childs[i], objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length - 1]);
                } else {
                    objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length] = new Object;
                    this.ParseXML(childs[i], objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length - 1]);
                }
            }
        }
        return objTarget;
    }
    this.XMLtoArray = function(docXml) {
        var obj = new Object();
        if (docXml) {
            for (var index = 0; index < docXml.childNodes.length; index++) {
                if (docXml.childNodes[index].nodeType == 1 || docXml.childNodes[index].nodeType == 9) {
                    this.ParseXMLAry(docXml.childNodes[index], obj);
                }
            }
        }
        return obj;
    }
    this.ParseXMLAry = function(docXml, objTarget) {
        for (var i = 0; i < docXml.attributes.length; i++) {
            objTarget[docXml.attributes[i].nodeName] = docXml.attributes[i].nodeValue;
        }
        var childs = docXml.childNodes;
        if (childs.length == 0) {
            objTarget.nodeValue = "";
        }
        for (i = 0; i < childs.length; i++) {
            if (childs[i].childNodes.length == 0 && childs[i].nodeType == 3) {
                objTarget.nodeValue = (childs[i].text || childs[i].textContent);
            } else {
                if (typeof (objTarget[childs[i].nodeName]) == 'undefined') {
                    objTarget[childs[i].nodeName] = new Array();
                    objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length] = new Object;
                    this.ParseXMLAry(childs[i], objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length - 1]);
                } else {
                    objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length] = new Object;
                    this.ParseXMLAry(childs[i], objTarget[childs[i].nodeName][objTarget[childs[i].nodeName].length - 1]);
                }
            }
        }
        return objTarget;
    }
    //    this.Encrypt=function(theText){
    //        var reText=new String();
    //    }
    //
    //    this.Decrypt=function(theText){
    //
    //    }
}
function RXMLDocument() {
    this.xmlDoc = null;
    if (typeof window.ActiveXObject != 'undefined') {/*Microsoft IE*/
        this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        this.xmlDoc.async = false;
        while (this.xmlDoc.readyState != 4) { };
    } else if (typeof document.implementation != 'undefined' && typeof document.implementation.createDocument != 'undefined') {/*Mozilla */
        this.xmlDoc = document.implementation.createDocument("", "", null);
    }
    this.loadXML = function(xmlstr) {
        if (window.event) {
            this.xmlDoc.loadXML(xmlstr);
        } else {
            var oParser = new DOMParser();
            this.xmlDoc = oParser.parseFromString(xmlstr, "text/xml");
        }
    }
    this.get = function() {
        return this.xmlDoc;
    }
    this.toString = function() {
        return 'RXMLDocument';
    }
}
//debugger
function RMap(left, top, width, height, lat, lng, zoom, maproot) {
    this.initlat = lat;
    this.initlng = lng;
    lat = parseFloat(lat);
    lng = parseFloat(lng);
    this.leftbottom = new RLatLng(0, 70);
    this.righttop = new RLatLng(60, 140);
    this.directorys = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15');
    this.scalefactors = new Array(30, 15, 10, 4, 2, 1, 0.4, 0.2, 0.1, 0.04, 0.02, 0.01, 0.004, 0.002, 0.001, 0.0004);
    this.gridfactors = new Array(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 40, 40, 40, 40, 40, 40);
    this.isScrolling = false;
    this.depthhandler = new RDepthHandler(100);
    this.tilewidth = 256;
    this.tileheight = 256;
    this.zoomlevels = this.directorys.length;
    this.availableMaxZoomLevel = this.zoomlevels - 1;
    this.SatelliteMaxZoomLevel = this.availableMaxZoomLevel;
    if (lat) { this.lat = lat; }
    else { this.lat = 1; }
    if (lng) { this.lng = lng; }
    else { this.lng = 1; }
    if (zoom < this.availableMaxZoomLevel) { this.zoom = zoom; }
    else if (zoom == this.availableMaxZoomLevel) { this.zoom = this.availableMaxZoomLevel - 1; }
    else { this.zoom = 0; }
    this.maproot = maproot;
    this.mapdb = this.maproot + '/typical/';
    this.left = left;
    this.top = top;
    this.width = width;
    this.height = height;
    this.markers = new Array();
    this.staticMarkers = new Array();
    this.tilelayers = new Array();
    this.container = new RDiv(this.left, this.top, this.width, this.height).get();
    this.style = this.container.style;
    this.container.style.clip = "rect(0 " + this.width + " " + this.height + " 0)";
    this.container.style.backgroundColor = '#DDDDDD';
    this.container.style.overflow = "hidden";
    this.container.style.visibility = "hidden";
    this.container.style.position = "relative";
    //    this.container.style.position="absolute";
    this.map = new RDiv(0, 0, this.width, this.height).get();
    this.map.style.backgroundColor = '#EBEAE8';
    this.map.style.zIndex = 99;
    this.markerdiv = new RDiv(0, 0, null, null).get();
    this.markerdiv.style.zIndex = 101;
    this.smoothMoveEventEnabled = true;
    this.boundsChangeEventEnabled = true;
    this.zoomChangeEventEnabled = true;
    this.keyReleaseEventEnabled = true;
    this.clickEventEnabled = true;
    this.mouseDownEventEnabled = true;
    this.zoomEnabled = true;
    this.dragEnabled = true;
    this.wheelZoomEnabled = true;
    this.keyPanEnabled = true;
    this.enableDblclick = true;
    this.searchEnabled = true;
    this.dynMoveEnabled = false;
    this.isdynMoveFlish = true;
    this.isFocus = false;
    this.mouseEvt = null;
    this.mouseX = 0;
    this.mouseY = 0;
    this.mapmask = new RDiv(0, 0, this.width, this.height).get();
    this.mapmask.style.zIndex = 100;
    this.mapmask.unselectable = 'off';
    this.mapmask.style.backgroundImage = 'url(' + JS_SERVER + '/rapi/rwidget/rmap/img/mask.gif)';
    this.mapmask.style.cursor = 'url(' + JS_SERVER + 'rapi/rwidget/rmap/img/openhand.cur),default';
    this.mapmask.root = this;
    this.mapmask.onmousewheel = function(evt) {//debugger
        if (this.addEventListener) {
            var x = (this.root.container.parentElement || this.root.container.parentNode).offsetLeft;
            var y = (this.root.container.parentElement || this.root.container.parentNode).offsetTop;
            var cx = evt.screenX;
            var cy = evt.screenY;
            if (cx < x || cy < y || cx > (x + this.root.width) || cy > (y + this.root.height)) {
                return;
            }
        }
        if (!this.root.wheelZoomEnabled) {
            return;
        }
        if (this.root.iszooming) {
            if (this.addEventListener) {
                evt.preventDefault();
            } else {
                window.event.returnValue = false;
            }
            return;
        }
        var zoom = 0;
        if ((evt || window.event).wheelDelta) {
            zoom = window.event.wheelDelta / 120
        } else {
            zoom = evt.detail / -3
        }
        if (zoom > 0) {
            this.root.setZoomLevel(this.root.zoom + 1);
        } else if (zoom < 0) {
            this.root.setZoomLevel(this.root.zoom - 1);
        }
        if (this.addEventListener) {
            evt.preventDefault();
        } else {
            window.event.returnValue = false;
        }
    }
    this.mapmask.onmousedown = function(evt) {
        this.mouseEvt = evt;
        this.root.mouseX = (evt || window.event).clientX;
        this.root.mouseY = (evt || window.event).clientY;
        if (this.root.mouseDownEventEnabled) {
            this.root.notify('onmousedown');
        }
        this.root.mouseDownEventEnabled = true;
        if (!evt) {
            this.setCapture();
        }
        if (!this.root.dragEnabled) { return; }
        this.drag = true;
        this.dragged = false;
        this.leftorigin = parseInt(this.root.map.style.left, 10);
        this.toporigin = parseInt(this.root.map.style.top, 10);
        this.xoffset = (evt || window.event).clientX - this.leftorigin;
        this.yoffset = (evt || window.event).clientY - this.toporigin;
        this.left = parseInt(this.root.map.style.left, 10);
        this.top = parseInt(this.root.map.style.top, 10);
        this.style.cursor = 'url(' + JS_SERVER + 'rapi/rwidget/rmap/img/closedhand.cur),move';
        setRTimeout(this, this.update, 1000);
    }
    this.mousemove = function(evt) {
        this.mouseEvt = evt;
        this.root.mouseX = (evt || window.event).clientX;
        this.root.mouseY = (evt || window.event).clientY;
        this.root.notify('onmousemoved');
        if (!this.root.dragEnabled) { return; }
        if (this.drag) {
            this.style.cursor = 'url(' + JS_SERVER + 'rapi/rwidget/rmap/img/closedhand.cur),move';
            this.dragged = true;
            this.root.drag(evt);
        }
    }
    this.mouseup = function(evt) {//debugger
        this.mouseEvt = evt;
        this.root.mouseX = (evt || window.event).clientX;
        this.root.mouseY = (evt || window.event).clientY;
        this.style.cursor = 'url(' + JS_SERVER + 'rapi/rwidget/rmap/img/openhand.cur),default';
        this.root.notify('onmouseup');
        if (!evt) {
            this.releaseCapture();
        }
        if (!this.root.dragEnabled) { return; }
        this.drag = false;
        if (this.dragged) {
            this.dragged = false;
            this.root.dragend(evt);
        }
    }
    this.drag = function(evt) {
        if (!this.dragEnabled) { return; }
        if (this.mapmask.drag) {
            this.map.style.left = (evt || window.event).clientX - this.mapmask.xoffset;
            this.map.style.top = (evt || window.event).clientY - this.mapmask.yoffset;
            this.markerdiv.style.left = (evt || window.event).clientX - this.mapmask.xoffset;
            this.markerdiv.style.top = (evt || window.event).clientY - this.mapmask.yoffset;
        }
    }
    this.dragend = function(evt) {
        if (!this.dragEnabled) { return; }
        var left = parseInt(this.map.style.left, 10);
        var top = parseInt(this.map.style.top, 10);
        var tmpLatLng = this.tilelayers[this.zoom].getLatLng(this.width / 2 - left, this.height / 2 - top);
        this.setCenter(tmpLatLng.lat, tmpLatLng.lng);
    }
    if (this.mapmask.addEventListener) {
        g_addListener("DOMMouseScroll", this.mapmask.onmousewheel, this.mapmask);
        window.addEventListener("DOMMouseScroll", g_notify, false);
        g_addListener("mousemove", this.mousemove, this.mapmask);
        document.addEventListener("mousemove", g_notify, false);
        g_addListener("mouseup", this.mouseup, this.mapmask);
        document.addEventListener("mouseup", g_notify, false);
    } else {
        this.mapmask.onmousemove = this.mousemove;
        this.mapmask.onmouseup = this.mouseup;
    }
    this.mapmask.onblur = function(evt) {
        this.root.isFocus = false;
    }
    this.mapmask.onfocus = function(evt) {
        this.root.isFocus = true;
    }
    this.mapmask.ondblclick = function(evt) {
        //	    this.mouseEvt=evt;
        //	    this.root.mouseX=(evt || window.event).clientX;
        //	    this.root.mouseY=(evt || window.event).clientY;
        //		if(this.root.enableDblclick){
        //		    this.root.dynMoveEnabled=false;
        //	        var left=(evt || window.event).clientX-(this.root.container.parentElement||this.root.container.parentNode).offsetLeft;
        //		    var top=(evt || window.event).clientY-((this.root.container.parentElement||this.root.container.parentNode).offsetTop-document.body.scrollTop);
        //		    var lk=this.root.container.parentNode.parentNode.parentNode.id;
        //		    if(this.root.isEagleMap){
        //		        if(this.addEventListener){
        //		            left=left-this.root.container.parentNode.parentNode.parentNode.offsetLeft;
        //		            top=top-this.root.container.parentNode.parentNode.parentNode.offsetTop;
        //		        }else{
        //		            left=left-this.root.container.parentElement.parentElement.parentElement.offsetLeft;
        //		            top=top-this.root.container.parentElement.parentElement.parentElement.offsetTop;
        //		        }
        //		    }
        //			this.root.moveTo(left,top);
        //			this.root.map.drag=false;
        //		}
        if (this.root.enableDblclick) {
            var bounds = getBoundingClientRect(this.root.get());
            var xoffset = this.root.mouseX - bounds.left;
            var yoffset = this.root.mouseY - bounds.top;
            this.root.moveTo(xoffset, yoffset);
            this.root.map.drag = false;
        }
        this.root.notify('ondblclicked');
    }
    this.recentkey = 0;
    if (!document.onkeydown) {
        document.root = this;
        document.onkeydown = function(evt) {
            if (!this.root.keyPanEnabled) {
                return;
            }
            var temp = this.root.mapmask;
            if (this.root.isFocus) {
                this.root.recentkey = (evt || window.event).keyCode;
                switch ((evt || window.event).keyCode) {
                    //A或左箭头  
                    case 65:
                    case 37:
                        this.root.panWest();
                        break;
                    //S或下箭头  
                    case 83:
                    case 40:
                        this.root.panSouth();
                        break;
                    // D或右箭头  
                    case 68:
                    case 39:
                        this.root.panEast();
                        break;
                    //W或上箭头  
                    case 87:
                    case 38:
                        this.root.panNorth();
                        break;
                    //+或PAGEUP  
                    case 187:
                    case 33:
                        this.root.zoomIn();
                        break;
                    //-或PAGEDOWN  
                    case 189:
                    case 34:
                        this.root.zoomOut();
                        break;
                    default:
                        break;
                }
                if (this.root.keyReleaseEventEnabled) {
                    this.root.notify('onkeyreleased');
                }
                this.root.keyReleaseEventEnabled = true;
            }
        }
    }
    this.mapmask.oncontextmenu = function() {
        this.root.notify('oncontextmenu');
    }
    this.mapmask.onclick = function() {
        if (this.root.clickEventEnabled) {
            this.root.notify('onclicked');
        }
        this.root.clickEventEnabled = true;
        this.focus();
    }
    this.mapmask.update = function() {
        if (!this.root.dragEnabled) { return; }
        if (!this.drag) { return; }
        var left = parseInt(this.root.map.style.left, 10);
        var top = parseInt(this.root.map.style.top, 10);
        if (this.left == left || this.top == top) {
            setRTimeout(this, this.update, 1000);
            return;
        }
        this.left = left;
        this.top = top;
        var tmpLatLng = this.root.tilelayers[this.root.zoom].getLatLng(this.root.width / 2 - this.left + this.leftorigin, this.root.height / 2 - this.top + this.toporigin);
        this.root.setCenter(tmpLatLng.lat, tmpLatLng.lng);
        this.xoffset = this.left + this.xoffset;
        this.yoffset = this.top + this.yoffset;
        this.root.map.style.left = this.leftorigin;
        this.root.map.style.top = this.toporigin;
        this.root.markerdiv.style.left = this.leftorigin;
        this.root.markerdiv.style.top = this.toporigin;
        this.left = parseInt(this.root.map.style.left, 10);
        this.top = parseInt(this.root.map.style.top, 10);
        setRTimeout(this, this.update, 1000);
    }
    this.container.appendChild(this.map);
    this.container.appendChild(this.mapmask);
    this.container.appendChild(this.markerdiv);
    tilelayerlistener = new Object();
    tilelayerlistener.root = this;
    tilelayerlistener.onsatelliteerror = function() {
        var txt = '当前区域部分卫片尚未开通';
        if (!this.root.errortip) {
            this.root.errortip = new RToolTip(this.root.width - (txt.length * 15 + 10), 5, txt, 10);
            this.root.get().appendChild(this.root.errortip.get());
        }
        if (!this.root.errortip.isVisible()) {
            this.root.errortip.setText(txt);
            this.root.errortip.show();
        }
    }
    tilelayerlistener.ontypicalerror = function() {
        var txt = '当前区域部分地图尚未开通';
        if (!this.root.errortip) {
            this.root.errortip = new RToolTip(this.root.width - (txt.length * 15 + 10), 5, txt, 10);
            this.root.get().appendChild(this.root.errortip.get());
        }
        if (!this.root.errortip.isVisible()) {
            this.root.errortip.setText(txt);
            this.root.errortip.show();
        }
    }
    for (var i = 0; i <= this.availableMaxZoomLevel; i++) {
        this.tilelayers[i] = new RTileLayer(this.tilewidth, this.tileheight, this.scalefactors[i], this.directorys[i], this.gridfactors[i], this.mapdb, this.width, this.height);
        this.tilelayers[i].addListener(tilelayerlistener, 'onsatelliteerror');
        this.tilelayers[i].addListener(tilelayerlistener, 'ontypicalerror');
        this.tilelayers[i].root = this;
        this.map.appendChild(this.tilelayers[i].get());
    }
    this.resetScaleFactors = function() {
        for (var i = 0; i < this.tilelayers.length; i++) {
            this.tilelayers[i].setScaleFactor(this.scalefactors[i]);
        }
    }
    this.toString = function() {
        return 'RMap';
    }
    this.show = function() {
        this.zoom = parseInt(this.zoom);
        for (var i = 0; i < this.tilelayers.length; i++) {
            this.tilelayers[i].style.zIndex = i;
            this.tilelayers[i].hide();
        }
        if (this.zoomdiffer == -1 && this.isValidZoom(this.zoom - 1)) {
            this.tilelayers[this.zoom - 1].style.zIndex = 100;
            this.tilelayers[this.zoom - 1].show();
        } else if (this.zoomdiffer == 1 && this.isValidZoom(this.zoom + 1)) {
            this.tilelayers[this.zoom + 1].style.zIndex = 100;
            this.tilelayers[this.zoom + 1].show();
        }
        this.zoomdiffer = 0;
        this.markerdiv.style.visibility = 'visible';
        this.tilelayers[this.zoom].style.left = 0;
        this.tilelayers[this.zoom].style.top = 0;
        this.tilelayers[this.zoom].zoom = 1;
        this.tilelayers[this.zoom].style.zIndex = 1000;
        this.tilelayers[this.zoom].show();
        this.container.style.visibility = "visible";
        if (this.toolbox) {
            this.toolbox.show();
        }
    }
    this.hide = function() {
        this.container.style.visibility = "hidden";
        this.markerdiv.style.visibility = 'hidden';
        this.map.style.visibility = 'hidden';
        for (var i = 0; i < this.tilelayers.length; i++) {
            this.tilelayers[i].hide();
        }
        if (this.toolbox) {
            this.toolbox.hide();
        }
    }
    this.iszooming = false;
    this.setZoomDirectly = function(zoom) {
        if (!this.zoomEnabled) { return; }
        this.iszooming = true;
        this.newzoom = zoom;
        if (this.newzoom < 0) {
            this.newzoom = 0;
        }
        if (this.newzoom > this.availableMaxZoomLevel) {
            this.newzoom = this.availableMaxZoomLevel;
        }
        if (this.zoom != this.newzoom) {
            this.tilelayers[this.newzoom].lat = this.lat;
            this.tilelayers[this.newzoom].lng = this.lng;
            this.zoom = this.newzoom;
            this.tilelayers[this.newzoom].setZoom(1);
            //			this.tilelayers[this.newzoom].style.zoom=1;
            //			this.tilelayers[this.newzoom].style.left=0;
            //			this.tilelayers[this.newzoom].style.top=0;
            this.refreshMap();
            if (this.zoomChangeEventEnabled) {
                this.notify('onzoomchanged');
            }
            this.zoomChangeEventEnabled = true;
        }
        this.iszooming = false;
    }
    this.setZoomLevelWithoutEvents = function(zoom) {
        this.zoomChangeEventEnabled = false;
        this.setZoomLevel(zoom);
    }
    this.setZoomLevel = function(zoom) {
        if (!this.zoomEnabled) { return; }
        this.iszooming = true;
        this.newzoom = zoom;
        if (this.newzoom < 0) {
            this.newzoom = 0;
        }
        if (this.newzoom > this.availableMaxZoomLevel) {
            this.newzoom = this.availableMaxZoomLevel;
        }
        if (this.zoom != this.newzoom) {
            this.hideMarkers();
            this.zoomdiffer = this.zoom - this.newzoom;
            this.hideOtherTileLayers();
            this.zoomtime = 15;
            this.zoomtime = Math.abs(this.zoomdiffer) * 3 + 10; //设置放大步数
            this.dynzoomdes = (this.scalefactors[this.zoom] / this.scalefactors[this.newzoom]);
            this.dynzoomstep = ((this.scalefactors[this.zoom] / this.scalefactors[this.newzoom]) - 1) / this.zoomtime;
            this.dynleftdes = -(this.dynzoomdes - 1) * this.width / 2;
            this.dyntopdes = -(this.dynzoomdes - 1) * this.height / 2;
            this.dynleftstep = (this.dynzoomstep * this.width) / 2;
            this.dyntopstep = (this.dynzoomstep * this.height) / 2;
            this.newdynzoomdes = 1;
            this.newdynzoomstep = (1 - (this.scalefactors[this.newzoom] / this.scalefactors[this.zoom])) / this.zoomtime;
            this.newdynleftdes = 0;
            this.newdyntopdes = 0;
            this.newdynleftstep = (this.newdynzoomstep * this.width) / 2;
            this.newdyntopstep = (this.newdynzoomstep * this.height) / 2;
            for (var iTile = 0; iTile < this.tilelayers.length; iTile++) {
                this.tilelayers[iTile].stopImages();
            }
            this.tilelayers[this.newzoom].set(this.lat, this.lng, this.width, this.height);
            this.tilelayers[this.newzoom].lat = this.lat;
            this.tilelayers[this.newzoom].lng = this.lng;
            this.map.style.backgroundColor = '';
            this.tilelayers[this.newzoom].setZoom(this.newdynzoomdes + 2 * this.newdynzoomstep);
            this.tilelayers[this.newzoom].style.zIndex = 999;
            this.tilelayers[this.newzoom].show();
            setRTimeout(this, this.dynZoom, 10);
        } else {
            this.iszooming = false;
        }
    }
    this.dynZoom = function() {
        this.tilelayers[this.newzoom].setZoom(this.newdynzoomdes - (--this.zoomtime) * this.newdynzoomstep);
        this.tilelayers[this.zoom].setZoom(this.dynzoomdes - this.zoomtime * this.dynzoomstep);
        if (this.zoomtime == 7) {
            this.tilelayers[this.newzoom].style.zIndex = 1000;
            this.tilelayers[this.zoom].style.zIndex = 999;
        }
        if (this.zoomtime > 0) {
            setRTimeout(this, this.dynZoom, 10);
        } else {
            this.zoom = this.newzoom;
            this.tilelayers[this.zoom].setZoom(1);
            this.hideMarkers();
            this.refreshMarkers();
            this.show();
            setRTimeout(this, this.finishDynZooming, 100);
        }
    }
    this.finishDynZooming = function() {
        if (this.zoomChangeEventEnabled) {
            this.notify('onzoomchanged');
        }
        this.zoomChangeEventEnabled = true;
        this.iszooming = false;
        if (this.dynMoveEnabled) {
            if (this.isdynMoveFlish) {
                this.dynMoveEnabled = false;
                this.notify('onsmoothmoved');
                this.notify('onzoomchanged');
                return;
            } else {
                this.isdynMoveFlish = true;
                this.smoothMoveWithoutEvents(this.dynMovelat, this.dynMovelng);
            }
        }
    }
    this.hideOtherTileLayers = function() {
        for (var iTile = 0; iTile < this.tilelayers.length; iTile++) {
            if (iTile == this.zoom) { continue; }
            this.tilelayers[iTile].hide();
        }
    }
    this.refreshMap = function() {
        for (var iTile = 0; iTile < this.tilelayers.length; iTile++) {
            this.tilelayers[iTile].stopImages();
        }
        this.hideMarkers();
        this.tilelayers[this.zoom].set(this.lat, this.lng, this.width, this.height);
        this.refreshMarkers();
        this.show();
    }
    this.paintMarker = function(marker) {
        var isValidMarker = false;
        var left = 0;
        var top = 0;
        switch (marker.toString()) {
            case "RPoint":
            case "RLabelPoint":
            case "RMapLabel":
            case "RBalloon":
                var tmp = this.tilelayers[this.zoom].getPixel(marker.lat, marker.lng);
                if (tmp) {
                    left = tmp.left + 1;
                    top = tmp.top + 1;
                    isValidMarker = true;
                }
                break;
            case "RGpsidArea": ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                //			    var tmp=this.tilelayers[this.zoom].getPixel(marker.lat,marker.lng);
                //				if(tmp){
                //				    left=tmp.left+1;
                //				    top=tmp.top+1;
                //				    isValidMarker=true;
                //				}
                var tmp1 = this.getPixel(marker.leftbottom.lat, marker.leftbottom.lng);
                var tmp2 = this.getPixel(marker.righttop.lat, marker.righttop.lng);
                var width = Math.abs(tmp2.left - tmp1.left);
                var height = Math.abs(tmp2.top - tmp1.top);
                left = (tmp1.left < tmp2.left) ? tmp1.left : tmp2.left;
                top = (tmp2.top < tmp1.top) ? tmp2.top : tmp1.top;
                if (marker.svg) {
                    marker.rect.setAttribute("width", width);
                    marker.rect.setAttribute("height", height);
                    marker.svg.setAttribute("width", width);
                    marker.svg.setAttribute("height", height);
                    marker.svg.setAttribute("viewBox", "0 0 " + width + " " + height);
                } else {
                    marker.rect.style.width = width;
                    marker.rect.style.height = height;
                }
                if (marker.gpsidAreaBox) {
                    marker.gpsidAreaBox.setLocation((width + 8) / 2, height / 2);
                }
                isValidMarker = true;
                break;
            case "RPath":
            case "RRegion":
                var points = "";
                var x1 = 0;
                var y1 = 0;
                var x2 = 0;
                var y2 = 0;
                if (this.mapmask.addEventListener) {
                    for (var index = 0; index < marker.latlngs.length; index++) {
                        if (index == 0) {
                            x1 = marker.latlngs[index].lat;
                            y1 = marker.latlngs[index].lng;
                            x2 = marker.latlngs[index].lat;
                            y2 = marker.latlngs[index].lng;
                        } else {
                            x1 = (x1 > marker.latlngs[index].lat) ? marker.latlngs[index].lat : x1;
                            y1 = (y1 < marker.latlngs[index].lng) ? marker.latlngs[index].lng : y1;
                            x2 = (x2 < marker.latlngs[index].lng) ? marker.latlngs[index].lat : x2;
                            y2 = (y2 > marker.latlngs[index].lng) ? marker.latlngs[index].lng : y2;
                        }
                    }
                    var pTmp = this.getPixel(x1, y1);
                    x1 = pTmp.left;
                    y1 = pTmp.top;
                    pTmp = this.getPixel(x2, y2);
                    x2 = pTmp.left;
                    y2 = pTmp.top;
                }
                var tmp;
                for (var i = 0; i < marker.latlngs.length; i++) {
                    tmp = this.tilelayers[this.zoom].getPixel(marker.latlngs[i].lat, marker.latlngs[i].lng);
                    if (this.mapmask.addEventListener) {
                        if (i == 0) {
                            points += "M" + (tmp.left - x2) + " " + (tmp.top - y2);
                        } else {
                            points += " L" + (tmp.left - x2) + " " + (tmp.top - y2);
                        }
                    } else {
                        points += tmp.left + "," + tmp.top + " ";
                    }
                }
                marker.repaintPolyline();
                if (this.mapmask.addEventListener) {
                    marker.setRegion(this.width, this.height);
                    marker.stroke.setAttribute("d", points);
                } else {
                    if (marker.toString() == "RPath") {
                        marker.setCap(marker.unStartCap, marker.unEndCap);
                    }
                    if (marker.polyline.points) {
                        marker.polyline.points.value = points;
                    } else {
                        marker.polyline.points = points;
                    }
                }
                isValidMarker = true;
                break;
            case 'RRectRegion':
            case 'RSquareMarker':
                var tmp1 = this.getPixel(marker.leftbottom.lat, marker.leftbottom.lng);
                var tmp2 = this.getPixel(marker.righttop.lat, marker.righttop.lng);
                var width = Math.abs(tmp2.left - tmp1.left);
                var height = Math.abs(tmp2.top - tmp1.top);
                left = (tmp1.left < tmp2.left) ? tmp1.left : tmp2.left;
                top = (tmp2.top < tmp1.top) ? tmp2.top : tmp1.top;
                if (marker.svg) {
                    marker.rect.setAttribute("width", width);
                    marker.rect.setAttribute("height", height);
                    marker.svg.setAttribute("width", width);
                    marker.svg.setAttribute("height", height);
                    marker.svg.setAttribute("viewBox", "0 0 " + width + " " + height);
                } else {
                    marker.rect.style.width = width;
                    marker.rect.style.height = height;
                }
                isValidMarker = true;
                break;
            case 'RCircleRegion':
                var tmp1 = this.getPixel(marker.center.lat - marker.radius, marker.center.lng - marker.radius);
                var tmp2 = this.getPixel(marker.center.lat + marker.radius, marker.center.lng + marker.radius);
                var width = Math.abs(tmp2.left - tmp1.left);
                var height = Math.abs(tmp2.top - tmp1.top);
                left = (tmp1.left < tmp2.left) ? tmp1.left : tmp2.left;
                top = (tmp2.top < tmp1.top) ? tmp2.top : tmp1.top;
                if (marker.svg) {
                    marker.oval.setAttribute("cx", Math.round(width / 2));
                    marker.oval.setAttribute("cy", Math.round(height / 2));
                    marker.oval.setAttribute("r", Math.floor(width / 2) - 1);
                    marker.svg.setAttribute("width", width);
                    marker.svg.setAttribute("height", height);
                    marker.svg.setAttribute("viewBox", "0 0 " + width + " " + height);
                } else {
                    marker.oval.style.width = width;
                    marker.oval.style.height = height;
                }
                isValidMarker = true;
                break;
            default:
                isValidMarker = false;
                break;
        }
        if (marker.div && isValidMarker) {
            marker.div.style.left = left;
            marker.div.style.top = top;
            this.markerdiv.appendChild(marker.div);
            //			this.mapmask.appendChild(marker.div);
        }
    }
    this.refreshMarkers = function() {
        this.showMarkers();
    }
    this.refreshStaticMarkers = function() {
        this.tilelayers[this.zoom].addMarkers(this.staticMarkers);
        this.tilelayers[this.zoom].showMarkers();
    }
    this.clearMarkers = function() {
        //如果正在测距，则关闭测距
        try {
            if (winDistanceTool.isLock == false) {
                winDistanceTool.turnoff();
            }
        } catch (e) { }
        //如果正在测面，则关闭测面
        try {
            if (winAreaTool.isLock == false) {
                winAreaTool.turnoff();
            }
        } catch (e) { }
        this.markers = new Array();
        this.staticMarkers = new Array();
        this.markerdiv.innerHTML = '';
        for (var i = 0; i < this.tilelayers.length; i++) {
            this.tilelayers[i].clearMarkers();
        }
    }
    this.clearStaticMarkers = function() {
        this.staticMarkers = new Array();
        for (var i = 0; i < this.tilelayers.length; i++) {
            this.tilelayers[i].clearMarkers();
        }
    }
    this.addMengniuMarker = function(minLatlng, maxLatlng, zIndex, fillcolor, strokecolor, opacity, boxType, title, content, maxContent) {
        var tmp = new RMengniu(this, minLatlng, maxLatlng, zIndex, fillcolor, strokecolor, opacity, boxType, title, content, maxContent);
        tmp.setMaximizeSize(this.width - 50, this.height - 100);

        var gpsidArealistener = new Object();
        gpsidArealistener.target = tmp;
        gpsidArealistener.maplet = this;

        gpsidArealistener.lat = this.lat;
        gpsidArealistener.lng = this.lng;
        gpsidArealistener.tmpC = tmp;
        gpsidArealistener.onboxopened = function() {
            var autoClose = false;
            for (var iMarker = 0; iMarker < this.maplet.markers.length; iMarker++) {
                if (this.maplet.markers[iMarker] == this.target) {
                    continue;
                }
                if (this.maplet.markers[iMarker].toString() == 'RGpsidArea') {
                    if (this.maplet.markers[iMarker].gpsidAreaBox.isOpen) {
                        this.maplet.markers[iMarker].hideBalloonBoxWithoutEvents();
                        autoClose = true;
                    }
                }
            }

            if (!autoClose) {
                this.lat = this.maplet.getCenter().lat;
                this.lng = this.maplet.getCenter().lng;
            }
            //			this.maplet.smoothMoveWithoutEvents(this.target.lat,this.target.lng);
            gpsidArealistener.tmpC.isOpenBalloon = true;

            //            //下调100px
            var lat = Math.round(this.target.lat * 100000) / 100000;
            var lng = Math.round(this.target.lng * 100000) / 100000;
            var tmp = this.maplet.tilelayers[this.maplet.zoom].getPixel(parseFloat(lat), parseFloat(lng));
            this.maplet.smoothMoveTo(tmp.left, tmp.top - 100);
        }
        gpsidArealistener.onboxmaximized = function() {
            if (this.maplet.toolbox) {
                if (this.maplet.toolbox.eagleMap) {
                    this.maplet.toolbox.eagleMap.hideEagleMap();
                }
            }
            var tmp = this.maplet.getLatLng((this.maplet.width) / 2 + 20, this.maplet.height - 50);
            var latdif = this.maplet.lat - tmp.lat;
            var lngdif = this.maplet.lng - tmp.lng;
            var lat = this.target.lat + latdif;
            var lng = this.target.lng + lngdif;
            this.maplet.smoothMoveWithoutEvents(lat, lng);
        }

        gpsidArealistener.onboxrestored = function() {
            //            //下调100px
            var lat = Math.round(this.target.lat * 100000) / 100000;
            var lng = Math.round(this.target.lng * 100000) / 100000;
            var tmp = this.maplet.tilelayers[this.maplet.zoom].getPixel(parseFloat(lat), parseFloat(lng));
            this.maplet.smoothMoveTo(tmp.left, tmp.top - 100);
            //			this.maplet.smoothMoveWithoutEvents(this.target.lat,this.target.lng);
        }

        gpsidArealistener.onmaxboxclosed = function() {
            if (this.lat && this.lng) {
                this.maplet.smoothMoveWithoutEvents(gpsidArealistener.target.lat, gpsidArealistener.target.lng);
            }

            gpsidArealistener.tmpC.isOpenBalloon = false;

        }

        tmp.addListener(gpsidArealistener, 'onboxopened');
        tmp.addListener(gpsidArealistener, 'onboxmaximized');
        tmp.addListener(gpsidArealistener, 'onboxrestored');
        tmp.addListener(gpsidArealistener, 'onmaxboxclosed');

        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addMarker = function(marker) {
        if (marker) {
            this.markers[this.markers.length] = marker;
        }
    }
    this.addLabelMarker = function(latlng, zIndex, icon, iconlabel, xoffset, yoffset, label, detail) {
        var tmp = new RLabelPoint(latlng, zIndex, icon, iconlabel, xoffset, yoffset, label, detail);
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addPointMarker = function(latlng, zIndex, icon, title, content, labelpath) {
        var tmp = new RPoint(latlng, zIndex, icon, title, content, labelpath);
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addMapLabelMarker = function(latlng, zIndex, content, opacity) {
        var tmp = new RMapLabel(latlng, zIndex, content, opacity);
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addGpsidAreaMarker = function(minLatlng, maxLatlng, zIndex, fillcolor, strokecolor, opacity, boxType, title, content, maxContent) {///////////////////////////////////////////////////////////////////////////////////////////
        var tmp = new RGpsidArea(this, minLatlng, maxLatlng, zIndex, fillcolor, strokecolor, opacity, boxType, title, content, maxContent);
        tmp.setMaximizeSize(this.width - 50, this.height - 100);
        var gpsidArealistener = new Object();
        gpsidArealistener.target = tmp;
        gpsidArealistener.maplet = this;
        gpsidArealistener.lat = this.lat;
        gpsidArealistener.lng = this.lng;
        gpsidArealistener.onboxopened = function() {
            var autoClose = false;
            for (var iMarker = 0; iMarker < this.maplet.markers.length; iMarker++) {
                if (this.maplet.markers[iMarker] == this.target) {
                    continue;
                }
                if (this.maplet.markers[iMarker].toString() == 'RGpsidArea') {
                    if (this.maplet.markers[iMarker].gpsidAreaBox.isOpen) {
                        this.maplet.markers[iMarker].hideBalloonBoxWithoutEvents();
                        autoClose = true;
                    }
                }
            }
            if (!autoClose) {
                this.lat = this.maplet.getCenter().lat;
                this.lng = this.maplet.getCenter().lng;
            }
            this.maplet.smoothMoveWithoutEvents(this.target.lat, this.target.lng);
            //            //下调100px
            //            var lat = Math.round(this.target.lat*100000)/100000;
            //            var lng = Math.round(this.target.lng*100000)/100000;
            //            var tmp=this.maplet.tilelayers[this.maplet.zoom].getPixel(parseFloat(lat),parseFloat(lng));
            //            this.maplet.smoothMoveTo(tmp.left,tmp.top-100);
        }
        gpsidArealistener.onboxmaximized = function() {
            if (this.maplet.toolbox) {
                if (this.maplet.toolbox.eagleMap) {
                    this.maplet.toolbox.eagleMap.hideEagleMap();
                }
            }
            var tmp = this.maplet.getLatLng((this.maplet.width) / 2 + 20, this.maplet.height - 50);
            var latdif = this.maplet.lat - tmp.lat;
            var lngdif = this.maplet.lng - tmp.lng;
            var lat = this.target.lat + latdif;
            var lng = this.target.lng + lngdif;
            this.maplet.smoothMoveWithoutEvents(lat, lng);
        }
        gpsidArealistener.onboxrestored = function() {
            this.maplet.smoothMoveWithoutEvents(this.target.lat, this.target.lng);
            //			var lat = Math.round(this.target.lat*100000)/100000;
            //            var lng = Math.round(this.target.lng*100000)/100000;
            //            var tmp=this.maplet.tilelayers[this.maplet.zoom].getPixel(parseFloat(lat),parseFloat(lng));
            //            this.maplet.smoothMoveTo(tmp.left,tmp.top-100);
        }
        gpsidArealistener.onmaxboxclosed = function() {
            if (this.lat && this.lng) {
                this.maplet.smoothMoveWithoutEvents(gpsidArealistener.target.lat, gpsidArealistener.target.lng);
            }
        }
        tmp.addListener(gpsidArealistener, 'onboxopened');
        tmp.addListener(gpsidArealistener, 'onboxmaximized');
        tmp.addListener(gpsidArealistener, 'onboxrestored');
        tmp.addListener(gpsidArealistener, 'onmaxboxclosed');
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addBalloonMarker = function(latlng, zIndex, icon, title, content, maxContent, isNone) {
        var tmp = new RBalloon(latlng, zIndex, icon, title, content, maxContent, isNone);
        tmp.setMaximizeSize(this.width - 2, this.height - 30);
        //		tmp.setBounds(this.get().getBoundingClientRect());
        tmp.setBounds(getBoundingClientRect(this.get()));
        var balloonlistener = new Object();
        balloonlistener.target = tmp;
        balloonlistener.maplet = this;
        balloonlistener.lat = this.lat;
        balloonlistener.lng = this.lng;
        balloonlistener.onboxopened = function() {
            var autoClose = false;
            for (var iMarker = 0; iMarker < this.maplet.markers.length; iMarker++) {
                if (this.maplet.markers[iMarker] == this.target) {
                    continue;
                }
                if (this.maplet.markers[iMarker].toString() == 'RBalloon') {
                    if (this.maplet.markers[iMarker].state == this.maplet.markers[iMarker].BOX_OPEN) {
                        this.maplet.markers[iMarker].hideBalloonBoxWithoutEvents();
                        autoClose = true;
                    }
                }
            }
            if (!autoClose) {
                this.lat = this.maplet.getCenter().lat;
                this.lng = this.maplet.getCenter().lng;
            }
            this.maplet.smoothMoveWithoutEvents(this.target.lat, this.target.lng);
            //            //下调100px
            //            var lat = Math.round(this.target.lat*100000)/100000;
            //            var lng = Math.round(this.target.lng*100000)/100000;
            //            var tmp=this.maplet.tilelayers[this.maplet.zoom].getPixel(parseFloat(lat),parseFloat(lng));
            //            this.maplet.smoothMoveTo(tmp.left,tmp.top-100);
        }
        balloonlistener.onboxmaximized = function() {
            if (this.maplet.toolbox) {
                if (this.maplet.toolbox.eagleMap) {
                    this.maplet.toolbox.eagleMap.hideEagleMap();
                }
            }
            var tmp = this.maplet.getLatLng(this.maplet.width / 2, this.maplet.height - 5);
            var latdif = this.maplet.lat - tmp.lat;
            var lngdif = this.maplet.lng - tmp.lng;
            var lat = this.target.lat + latdif;
            var lng = this.target.lng + lngdif;
            this.maplet.smoothMoveWithoutEvents(lat, lng);
        }
        balloonlistener.onboxrestored = function() {
            this.maplet.smoothMoveWithoutEvents(this.target.lat, this.target.lng);
            //			var lat = Math.round(this.target.lat*100000)/100000;
            //            var lng = Math.round(this.target.lng*100000)/100000;
            //            var tmp=this.maplet.tilelayers[this.maplet.zoom].getPixel(parseFloat(lat),parseFloat(lng));
            //            this.maplet.smoothMoveTo(tmp.left,tmp.top-100);
        }
        balloonlistener.onmaxboxclosed = function() {
            if (this.lat && this.lng) {
                this.maplet.smoothMoveWithoutEvents(balloonlistener.target.lat, balloonlistener.target.lng);
            }
        }
        balloonlistener.onDragEnd = function() {
            tmp.latlng = this.maplet.getLatLng(parseInt(tmp.div.style.left), parseInt(tmp.div.style.top));
            tmp.lat = tmp.latlng.lat;
            tmp.lng = tmp.latlng.lng;
        }
        balloonlistener.onBoundsChangeStopped = function() {
        }
        tmp.addListener(balloonlistener, 'onboxopened');
        tmp.addListener(balloonlistener, 'onboxmaximized');
        tmp.addListener(balloonlistener, 'onboxrestored');
        tmp.addListener(balloonlistener, 'onmaxboxclosed');
        tmp.addListener(balloonlistener, 'onDragEnd');
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addPathMarker = function(latlngs, color, weight, opacity) {
        var tmp = new RPath(latlngs, color, weight, opacity);
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addStaticRectRegionMarker = function(bounds, fillcolor) {
        var tmp = new RRectRegion(bounds, fillcolor);
        this.staticMarkers[this.staticMarkers.length] = tmp;
        return tmp;
    }
    this.addStaticSquareMarker = function(bounds, fillcolor, strokecolor, Opacity) {
        var tmp = new RSquareMarker(bounds, fillcolor, strokecolor, Opacity);
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.addStaticCircleRegionMarker = function(center, radius, fillcolor) {
        var tmp = new RCircleRegion(center, radius, fillcolor);
        this.staticMarkers[this.staticMarkers.length] = tmp;
        return tmp;
    }
    this.addStaticPathMarker = function(latlngs, color, weight, opacity, unStartCap, unEndCap) {
        var tmp = new RPath(latlngs, color, weight, opacity);
        tmp.unStartCap = unStartCap;
        tmp.unEndCap = unEndCap;
        this.staticMarkers[this.staticMarkers.length] = tmp;
        return tmp;
    }
    this.addStaticRegionMarker = function(latlngs, color, fillcolor, weight) {
        var tmp = new RRegion(latlngs, color, fillcolor, weight);
        this.staticMarkers[this.staticMarkers.length] = tmp;
        return tmp;
    }
    this.addRegionMarker = function(latlngs, color, fillcolor, weight) {
        var tmp = new RRegion(latlngs, color, fillcolor, weight);
        this.markers[this.markers.length] = tmp;
        return tmp;
    }
    this.onzoomchanged = new Array();
    this.onboundschanged = new Array();
    this.onresized = new Array();
    this.onclicked = new Array();
    this.ondblclicked = new Array();
    this.onmousemoved = new Array();
    this.ontypechanged = new Array();
    this.onmousedown = new Array();
    this.onmouseup = new Array();
    this.oncontextmenu = new Array();
    this.onkeyreleased = new Array();
    this.onsmoothmoved = new Array();
    this.onBoundsChangeStopped = new Array();
    this.onMaxlevelUpdated = new Array();
    this.onSatelliteMaxlevelUpdated = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onBoundsChangeStopped':
                if (listener.onBoundsChangeStopped) {
                    this.onBoundsChangeStopped[this.onBoundsChangeStopped.length] = listener;
                }
                break;
            case 'onMaxlevelUpdated':
                if (listener.onMaxlevelUpdated) {
                    this.onMaxlevelUpdated[this.onMaxlevelUpdated.length] = listener;
                }
                break;
            case 'onSatelliteMaxlevelUpdated':
                if (listener.onSatelliteMaxlevelUpdated) {
                    this.onSatelliteMaxlevelUpdated[this.onSatelliteMaxlevelUpdated.length] = listener;
                }
                break;
            case 'onboundschanged':
                if (listener.onboundschanged) { this.onboundschanged[this.onboundschanged.length] = listener; }
                break;
            case 'onzoomchanged':
                if (listener.onzoomchanged) { this.onzoomchanged[this.onzoomchanged.length] = listener; }
                break;
            case 'onresized':
                if (listener.onresized) { this.onresized[this.onresized.length] = listener; }
                break;
            case 'onclicked':
                if (listener.onclicked) { this.onclicked[this.onclicked.length] = listener; }
                break;
            case 'ondblclicked':
                if (listener.ondblclicked) { this.ondblclicked[this.ondblclicked.length] = listener; }
                break;
            case 'onmousemoved':
                if (listener.onmousemoved) { this.onmousemoved[this.onmousemoved.length] = listener; }
                break;
            case 'ontypechanged':
                if (listener.ontypechanged) { this.ontypechanged[this.ontypechanged.length] = listener; }
                break;
            case 'onmousedown':
                if (listener.onmousedown) { this.onmousedown[this.onmousedown.length] = listener; }
                break;
            case 'onmouseup':
                if (listener.onmouseup) { this.onmouseup[this.onmouseup.length] = listener; }
                break;
            case 'oncontextmenu':
                if (listener.oncontextmenu) { this.oncontextmenu[this.oncontextmenu.length] = listener; }
                break;
            case 'onkeyreleased':
                if (listener.onkeyreleased) { this.onkeyreleased[this.onkeyreleased.length] = listener; }
                break;
            case 'onsmoothmoved':
                if (listener.onsmoothmoved) { this.onsmoothmoved[this.onsmoothmoved.length] = listener; }
                break;
            default:
                window.status = 'RMap类不存在事件' + estring;
                break;
        }
    }
    this.BoundsChangeCount = 0;
    this.isBoundsChangeStopped = function(tBoundsChangeCount) {
        if (this.BoundsChangeCount == tBoundsChangeCount) {
            this.BoundsChangeCount = 0;
            this.notify('onBoundsChangeStopped');
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onBoundsChangeStopped':
                for (var i = 0; i < this.onBoundsChangeStopped.length; i++) {
                    if (this.onBoundsChangeStopped[i].onBoundsChangeStopped) {
                        this.onBoundsChangeStopped[i].onBoundsChangeStopped();
                    }
                }
                break;
            case 'onMaxlevelUpdated':
                for (var i = 0; i < this.onMaxlevelUpdated.length; i++) {
                    if (this.onMaxlevelUpdated[i].onMaxlevelUpdated) {
                        this.onMaxlevelUpdated[i].onMaxlevelUpdated();
                    }
                }
                if (this.availableMaxZoomLevel < this.zoom) {
                    var txt = '当前为止地图尚未开通';
                    if (!this.errortip) {
                        this.errortip = new RToolTip(this.width - (txt.length * 15 + 10), 5, txt, 10);
                        this.get().appendChild(this.errortip.get());
                    }
                    this.errortip.setText('当前位置第' + this.zoom + '等级图片尚未开通，地图自动向上缩放' + (this.zoom - this.availableMaxZoomLevel) + '个等级');
                    this.errortip.show();
                    this.setZoomLevel(this.availableMaxZoomLevel);
                }
                break;
            case 'onSatelliteMaxlevelUpdated':
                for (var i = 0; i < this.onSatelliteMaxlevelUpdated.length; i++) {
                    if (this.onSatelliteMaxlevelUpdated[i].onSatelliteMaxlevelUpdated) {
                        this.onSatelliteMaxlevelUpdated[i].onSatelliteMaxlevelUpdated();
                    }
                }
                break;
            case 'onboundschanged':
                this.BoundsChangeCount++;
                setRTimeout(this, this.isBoundsChangeStopped, 1500, [this.BoundsChangeCount]);
                for (var i = 0; i < this.onboundschanged.length; i++) {
                    if (this.onboundschanged[i].onboundschanged) {
                        this.onboundschanged[i].onboundschanged();
                    }
                }
                break;
            case 'onzoomchanged':
                for (var i = 0; i < this.onzoomchanged.length; i++) {
                    if (this.onzoomchanged[i].onzoomchanged) {
                        this.onzoomchanged[i].onzoomchanged();
                    }
                }
                if (this.boundsChangeEventEnabled) {
                    this.notify('onboundschanged');
                }
                this.boundsChangeEventEnabled = true;
                break;
            case 'onresized':
                for (var i = 0; i < this.onresized.length; i++) {
                    if (this.onresized[i].onresized) {
                        this.onresized[i].onresized();
                    }
                }
                break;
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    }
                }
                break;
            case 'ondblclicked':
                for (var i = 0; i < this.ondblclicked.length; i++) {
                    if (this.ondblclicked[i].ondblclicked) {
                        this.ondblclicked[i].ondblclicked();
                    }
                }
                break;
            case 'onmousemoved':
                for (var i = 0; i < this.onmousemoved.length; i++) {
                    if (this.onmousemoved[i].onmousemoved) {
                        this.onmousemoved[i].onmousemoved();
                    }
                }
                break;
            case 'ontypechanged':
                for (var i = 0; i < this.ontypechanged.length; i++) {
                    if (this.ontypechanged[i].ontypechanged) {
                        this.ontypechanged[i].ontypechanged();
                    }
                }
                break;
            case 'onmousedown':
                for (var i = 0; i < this.onmousedown.length; i++) {
                    if (this.onmousedown[i].onmousedown) {
                        this.onmousedown[i].onmousedown();
                    }
                }
                break;
            case 'onmouseup':
                for (var i = 0; i < this.onmouseup.length; i++) {
                    if (this.onmouseup[i].onmouseup) {
                        this.onmouseup[i].onmouseup();
                    }
                }
                break;
            case 'oncontextmenu':
                for (var i = 0; i < this.oncontextmenu.length; i++) {
                    if (this.oncontextmenu[i].oncontextmenu) {
                        this.oncontextmenu[i].oncontextmenu();
                    }
                }
                break;
            case 'onkeyreleased':
                for (var i = 0; i < this.onkeyreleased.length; i++) {
                    if (this.onkeyreleased[i].onkeyreleased) {
                        this.onkeyreleased[i].onkeyreleased();
                    }
                }
                break;
            case 'onsmoothmoved':
                for (var i = 0; i < this.onsmoothmoved.length; i++) {
                    if (this.onsmoothmoved[i].onsmoothmoved) {
                        this.onsmoothmoved[i].onsmoothmoved();
                    }
                }
                break;
            default:
                window.status = 'RMap通报了一个未知的事件' + estring;
                break;
        }
    }
    this.panWest = function() {
        this.smoothMoveTo(this.width / 2 - this.width / 3, this.height / 2);
    }
    this.panSouth = function() {
        this.smoothMoveTo(this.width / 2, this.height / 2 + this.height / 3);
    }
    this.panEast = function() {
        this.smoothMoveTo(this.width / 2 + this.width / 3, this.height / 2);
    }
    this.panNorth = function() {
        this.smoothMoveTo(this.width / 2, this.height / 2 - this.height / 3);
    }
    this.zoomIn = function() {
        var zoom = this.zoom + 1;
        this.setZoomLevel(zoom);
    }
    this.zoomOut = function() {
        var zoom = this.zoom - 1;
        this.setZoomLevel(zoom);
    }
    this.comeback = function() {
        this.dynSmoothMove(this.initlat, this.initlng, this.initzoom);
    }
    this.moveTo = function(left, top) {
        this.smoothMoveTo(left, top);
    }
    this.getLatLngInRegion = function(lat, lng) {
        if (!(this.leftbottom && this.righttop)) {
            return new RLatLng(lat, lng);
        }
        if (this.leftbottom.toString() != 'RLatLng' || this.righttop.toString() != 'RLatLng') {
            return new RLatLng(lat, lng);
        }
        lat = (lat < this.leftbottom.lat) ? this.leftbottom.lat : lat;
        lat = (lat > this.righttop.lat) ? this.righttop.lat : lat;
        lng = (lng < this.leftbottom.lng) ? this.leftbottom.lng : lng;
        lng = (lng > this.righttop.lng) ? this.righttop.lng : lng;
        return new RLatLng(lat, lng);
    }
    this.setCenterWithoutEvents = function(lat, lng) {
        this.boundsChangeEventEnabled = false;
        this.setCenter(lat, lng);
    }
    this.setCenter = function(lat, lng) {
        lat = parseFloat(lat);
        lng = parseFloat(lng);
        if (!(lat > -90 && lat < 90) || !(lng > -180 && lng < 180)) {
            window.status = '企图使用非法的经纬度定位地图';
            return;
        }
        var latlng = this.getLatLngInRegion(lat, lng);
        lat = latlng.lat;
        lng = latlng.lng;
        if ((lat == this.lat) && (lng == this.lng)) {
            this.map.style.left = 0;
            this.map.style.top = 0;
            this.markerdiv.style.left = 0;
            this.markerdiv.style.top = 0;
            return;
        }
        this.calculateAvailableMaxZoomLevel(latlng);
        this.hideOtherTileLayers();
        this.lat = lat;
        this.lng = lng;
        this.hideMarkers();
        this.tilelayers[this.zoom].set(this.lat, this.lng, this.width, this.height);
        this.map.style.left = 0;
        this.map.style.top = 0;
        this.markerdiv.style.left = 0;
        this.markerdiv.style.top = 0;
        this.refreshMarkers();
        if (this.boundsChangeEventEnabled) {
            this.notify('onboundschanged');
        }
        this.boundsChangeEventEnabled = true;
    }
    this.maptype = 'typical';
    this.setMapType = function(maptype) {
        if (maptype == this.maptype) { return; }
        switch (maptype) {
            case 'typical':
                this.oldmaptype = this.maptype;
                this.maptype = maptype;
                this.hideOtherTileLayers();
                this.mapdb = this.maproot + '/typical/';
                for (var i = 0; i < this.tilelayers.length; i++) {
                    this.tilelayers[i].setHybrid(false);
                    this.tilelayers[i].mapdb = this.mapdb;
                }
                this.leftbottom = null;
                this.righttop = null;
                this.tilelayers[10].setScaleFactor(this.scalefactors[10]);
                this.zoomEnabled = true;
                this.refreshMap();
                this.notify('ontypechanged');
                break;
            case 'satellite':
                this.oldmaptype = this.maptype;
                this.maptype = maptype;
                this.hideOtherTileLayers();
                this.mapdb = this.maproot + '/satellite/';
                for (var i = 0; i < this.tilelayers.length; i++) {
                    this.tilelayers[i].setHybrid(false);
                    this.tilelayers[i].mapdb = this.mapdb;
                }
                this.refreshMap();
                this.notify('ontypechanged');
                break;
            case 'hybrid':
                this.oldmaptype = this.maptype;
                this.maptype = maptype;
                this.hideOtherTileLayers();
                this.mapdb = this.maproot + '/typical/';
                for (var i = 0; i < this.tilelayers.length; i++) {
                    this.tilelayers[i].setHybrid(true);
                    this.tilelayers[i].mapdb = this.mapdb;
                }
                this.leftbottom = null;
                this.righttop = null;
                this.tilelayers[10].setScaleFactor(this.scalefactors[10]);
                this.zoomEnabled = true;
                this.refreshMap();
                this.notify('ontypechanged');
                break;
            case 'thematic':
                this.oldmaptype = this.maptype;
                this.maptype = maptype;
                this.hideOtherTileLayers();
                this.mapdb = this.maproot + '/thematic/';
                for (var i = 0; i < this.tilelayers.length; i++) {
                    this.tilelayers[i].mapdb = this.mapdb;
                }
                this.refreshMap();
                this.notify('ontypechanged');
                break;
            default:
                window.status = "RMap不存在该地图类型" + maptype;
                break;
        }
    }
    this.getCenter = function() {
        return new RLatLng((Math.round(this.lat * 100000) / 100000), (Math.round(this.lng * 100000) / 100000));
    }
    this.getBounds = function() {
        var leftbottom = new RLatLng(Math.round((this.lat - this.scalefactors[this.zoom] * this.height / 2 / this.tileheight) * 100000) / 100000, Math.round((this.lng - this.scalefactors[this.zoom] * this.width / 2 / this.tilewidth) * 100000) / 100000);
        var righttop = new RLatLng(Math.round((this.lat + this.scalefactors[this.zoom] * this.height / 2 / this.tileheight) * 100000) / 100000, Math.round((this.lng + this.scalefactors[this.zoom] * this.width / 2 / this.tilewidth) * 100000) / 100000);
        return new RBounds(leftbottom, righttop);
    }
    this.getSearchBounds = function() {
        var margin = 50; //空白为50px
        var leftbottom = this.getLatLng(margin, this.height - margin);
        var righttop = this.getLatLng(this.width - margin, margin);
        return new RBounds(leftbottom, righttop);
    }
    this.getZoomLevel = function() {
        return this.zoom;
    }
    this.get = function() {
        return this.container;
    }
    this.sliding = false;
    this.slideCounter = 0;
    this.speed = 15;
    this.smoothMoveWithoutEvents = function(lat, lng) {
        this.smoothMoveEventEnabled = false;
        this.boundsChangeEventEnabled = false;
        this.smoothMove(lat, lng);
    }
    this.smoothMove = function(lat, lng) {
        lat = Math.round(lat * 100000) / 100000;
        lng = Math.round(lng * 100000) / 100000;
        if (this.lat == lat && this.lng == lng) { return; }
        var tmp = this.tilelayers[this.zoom].getPixel(parseFloat(lat), parseFloat(lng));
        this.smoothMoveTo(tmp.left, tmp.top);
    }
    this.dynSmoothMove = function(lat, lng, zoom) {
        lat = Math.round(lat * 100000) / 100000;
        lng = Math.round(lng * 100000) / 100000;
        if (zoom) {
            this.dynMovezoom = zoom;
        } else {
            this.dynMovezoom = this.zoom;
        }
        if (this.lat == lat && this.lng == lng && this.zoom == this.dynMovezoom) { return; }
        else if (this.lat == lat && this.lng == lng && this.zoom != this.dynMovezoom) {
            this.setZoomLevel(zoom);
            return;
        }
        this.dynMoveEnabled = true;
        this.dynMovelat = lat;
        this.dynMovelng = lng;
        if (this.zoom <= this.getMaxZoomByLatLng(new RLatLng(lat, lng))) {
            this.boundsChangeEventEnabled = false;
            this.smoothMoveWithoutEvents(lat, lng)
        } else {
            this.boundsChangeEventEnabled = false;
            this.isdynMoveFlish = false;
            this.setZoomLevelWithoutEvents(this.getMaxZoomByLatLng(new RLatLng(lat, lng)));
        }
    }
    this.smoothMoveTo = function(left, top) {
        if (!this.sliding) {
            this.sliding = true;
            this.xoffset = left;
            this.yoffset = top;
            this.leftdes = parseInt(this.map.style.left, 10);
            this.topdes = parseInt(this.map.style.top, 10);
            this.subDistance = Math.abs(this.width / 2 - left) > Math.abs(this.height / 2 - top) ? Math.abs(this.width / 2 - left) : Math.abs(this.height / 2 - top);
            this.speed = Math.round(this.subDistance / 70);
            this.speed = this.speed + 10;
            if (this.speed > 20) {
                this.speed = 20;
            }
            this.xstep = (this.width / 2 - left) / this.speed;
            this.ystep = (this.height / 2 - top) / this.speed;
            this.doSlide();
        }
    }
    this.doSlide = function() {
        if (this.slideCounter < this.speed) {
            this.map.style.left = this.leftdes + (this.slideCounter + 1) * this.xstep;
            this.map.style.top = this.topdes + (this.slideCounter + 1) * this.ystep;
            this.markerdiv.style.left = this.leftdes + (this.slideCounter + 1) * this.xstep;
            this.markerdiv.style.top = this.topdes + (this.slideCounter + 1) * this.ystep;
            this.slideCounter++;
            setRTimeout(this, this.doSlide, 10);
        } else {
            setRTimeout(this, this.finishSlide, 10);
        }
    }
    this.finishSlide = function() {
        this.slideCounter = 0;
        this.sliding = false;
        var tmp = this.tilelayers[this.zoom].getLatLng(this.xoffset, this.yoffset);
        this.setCenter(tmp.lat, tmp.lng);
        if (this.smoothMoveEventEnabled) {
            this.notify('onsmoothmoved');
        }
        this.smoothMoveEventEnabled = true;
        if (this.dynMoveEnabled) {
            this.setCenter(parseFloat(this.dynMovelat), parseFloat(this.dynMovelng));
            if (this.zoom != this.dynMovezoom) {
                this.setZoomLevelWithoutEvents(this.dynMovezoom);
            } else {
                this.isdynMoveFlish = true;
                this.dynMoveEnabled = false;
                this.notify('onsmoothmoved');
                this.notify('onzoomchanged');
                return;
            }
        }
    }
    this.getToolBox = function(src) {
        this.toolbox = new RToolBox(this, "left", src);
        return this.toolbox;
    }
    this.resize = function(width, height) {
        this.width = width;
        this.height = height;
        this.container.style.clip = 'rect(0 ' + this.width + ' ' + this.height + ' 0)';
        this.container.style.width = this.width;
        this.container.style.height = this.height;
        this.mapmask.style.width = this.width;
        this.mapmask.style.height = this.height;
        this.refreshMap();
        this.notify('onresized');
    }
    this.getZoomByPoints = function(latlngs) {
    }
    this.getCenterByPoints = function(latlngs) {
        var lat = 0;
        var lng = 0;
        for (var i = 0; i < latlngs.length; i++) {
            lat += latlngs.lat;
            lng += latlngs.lng;
        }
        lat = Math.round((lat / latlngs.length) * 100000) / 100000;
        lng = Math.round((lng / latlngs.length) * 100000) / 100000;
        return new RLatLng(lat, lng);
    }
    this.setCursor = function(cursor) {
        this.mapmask.style.cursor = cursor;
    }
    this.getPixel = function(lat, lng) {
        return this.tilelayers[this.zoom].getPixel(parseFloat(lat), parseFloat(lng));
    }
    this.getLatLng = function(left, top) {
        return this.tilelayers[this.zoom].getLatLng(left, top);
    }
    this.getMaskLayer = function() {
        return this.mapmask;
    }
    this.isValidZoom = function(zoom) {
        return zoom >= 0 && zoom <= this.availableMaxZoomLevel;
    }
    this.hideMarkers = function() {
        this.markerdiv.style.visibility = 'hidden';
        this.tilelayers[this.zoom].hideMarkers();
    }
    this.showMarkers = function() {
        for (var iMarker = 0; iMarker < this.markers.length; iMarker++) {
            this.paintMarker(this.markers[iMarker]);
        }
        this.tilelayers[this.zoom].addMarkers(this.staticMarkers);
        this.tilelayers[this.zoom].showMarkers();
        this.markerdiv.style.visibility = 'visible';
    }
    this.enableSearch = function() {
        this.searchEnabled = true;
    }
    this.disableSearch = function() {
        this.searchEnabled = false;
    }
    this.hideMarkers();
    this.tilelayers[this.zoom].set(this.lat, this.lng, this.width, this.height);
    this.refreshMarkers();
    this.disableZoom = function() {
        this.zoomEnabled = false;
    }
    this.enableZoom = function() {
        this.zoomEnabled = true;
    }
    this.setMaxBounds = function(leftbottom, righttop) {
        this.leftbottom = leftbottom;
        this.righttop = righttop;
    }
    this.enableDrag = function() {
        this.dragEnabled = true;
    }
    this.disableDrag = function() {
        this.dragEnabled = false;
    }
    this.enableDoubleClick = function() {
        this.enableDblclick = true;
    }
    this.disableDoubleClick = function() {
        this.enableDblclick = false;
    }
    this.disableKeyPan = function() {
        this.keyPanEnabled = false;
    }
    this.enableKeyPan = function() {
        this.keyPanEnabled = true;
    }
    this.disableWheelZoom = function() {
        this.wheelZoomEnabled = false;
    }
    this.enableWheelZoom = function() {
        this.wheelZoomEnabled = true;
    }
    this.isReturnboundsCenter = false;
    this.boundsCenter = null;
    ///modify:Jancion;Time:070606
    ///同时显示当前点（保持原来的位置）与关联点的位置
    ///如果寻找不到合适的比例尺就默认返回原来的比例尺
    this.getMaxZoomByLatLng = function(latlng, nMargin, endCenter) {
        if (!nMargin) {
            nMargin = 50;
        }
        if (endCenter) {
            for (var iZoom = this.availableMaxZoomLevel; iZoom > 0; iZoom--) {
                if ((Math.abs(latlng.lat - endCenter.lat) / this.scalefactors[iZoom] * this.tileheight < (this.height / 2 - nMargin)) && (Math.abs(latlng.lng - endCenter.lng) / this.scalefactors[iZoom] * this.tilewidth < (this.width / 2 - nMargin))) {
                    return iZoom;
                }
            }
        } else {
            for (var iZoom = this.availableMaxZoomLevel; iZoom > 0; iZoom--) {
                if ((Math.abs(latlng.lat - this.lat) / this.scalefactors[iZoom] * this.tileheight < (this.height / 2 - nMargin)) && (Math.abs(latlng.lng - this.lng) / this.scalefactors[iZoom] * this.tilewidth < (this.width / 2 - nMargin))) {
                    return iZoom;
                }
            }
        }
        return 0;
    }
    ///Author:Jancion;Time:070606
    ///通过经纬度数组来确定显示最合适边框（合适的比例尺与合适的中心点）
    ///不考虑当前点，只针对数组自身数字进行范围定位
    ///@1:需要显示的经纬度集合
    ///@2:是否保存当前中心点
    this.setMaxBoundsByLatLngs = function(nLatLngs, nIsSaveCenter, nMargin) {
        if (!nMargin) {
            nMargin = 50;
        }
        if (nLatLngs != null && nLatLngs.length > 0) {
            var cArrayLength = nLatLngs.length;
            if (cArrayLength == 1) {//数组仅一项时，
                if (nIsSaveCenter) {
                    var cZoom = this.getMaxZoomByLatLng(nLatLngs[0]);
                    this.setZoomDirectly(cZoom);
                } else {
                    this.setZoomDirectly(11);
                    this.setCenter(nLatLngs[0].lat, nLatLngs[0].lng);
                }
            } else {
                if (nIsSaveCenter == true) {
                    var cCurrentLatLng = new RLatLng(this.lat, this.lng);
                    var cMaxLatLng = this.getMaxLatLngFromArray(nLatLngs, cCurrentLatLng);
                    if (cMaxLatLng != null) {
                        var cZoom = this.getMaxZoomByLatLng(cMaxLatLng, nMargin);
                        this.setZoomDirectly(cZoom);
                    } else { return; }
                } else {
                    var cMaxLatLng = this.getMaxLatLngFromArray(nLatLngs);
                    if (cMaxLatLng != null) {
                        var cZoom = this.getMaxZoomByLatLng(cMaxLatLng, nMargin);
                        this.setZoomDirectly(cZoom);
                    } else { return; }
                }
            }
        } else { return; }
    }
    //setMaxBoundsByLatLngs功能的动态移动的实现
    this.dynSetMaxBoundsByLatLngs = function(nLatLngs, nIsSaveCenter, nMargin) {
        if (!nMargin) {
            nMargin = 50;
        }
        if (nLatLngs != null && nLatLngs.length > 0) {
            var cArrayLength = nLatLngs.length;
            if (cArrayLength == 1) {//数组仅一项时，
                if (nIsSaveCenter) {
                    var cZoom = this.getMaxZoomByLatLng(nLatLngs[0]);
                    this.setZoomLevel(cZoom);
                } else {
                    this.dynSmoothMove(nLatLngs[0].lat, nLatLngs[0].lng, 11);
                }
            } else {
                if (nIsSaveCenter) {
                    var cCurrentLatLng = new RLatLng(this.lat, this.lng);
                    var cMaxLatLng = this.getMaxLatLngFromArray(nLatLngs, cCurrentLatLng);
                    if (cMaxLatLng != null) {
                        var cZoom = this.getMaxZoomByLatLng(cMaxLatLng, nMargin);
                        this.setZoomLevel(cZoom);
                    } else { return; }
                } else {
                    this.isReturnboundsCenter = true;
                    var cMaxLatLng = this.getMaxLatLngFromArray(nLatLngs);
                    this.isReturnboundsCenter = false;
                    if (cMaxLatLng != null) {
                        if (this.boundsCenter) {
                            var cZoom = this.getMaxZoomByLatLng(cMaxLatLng, nMargin, this.boundsCenter);
                            this.dynSmoothMove(this.boundsCenter.lat, this.boundsCenter.lng, cZoom);
                        }
                    } else { return; }
                }
            }
        } else { return; }
    }
    ///从数组中计算出最大经度与最大纬度的，并组合成一点返回
    ///包含当前的位置，就是以当前位置为中心
    this.getMaxLatLngFromArray = function(nLatLngs, nCurrentLatLng) {
        if (nCurrentLatLng) {
            if (nLatLngs != null && nLatLngs.length > 0) {
                var cArrayLength = nLatLngs.length;
                var cMaxLat = Math.abs(nLatLngs[0].lat - nCurrentLatLng.lat);
                var cMaxLng = Math.abs(nLatLngs[0].lng - nCurrentLatLng.lng);
                for (var cIndex = 1; cIndex < cArrayLength; cIndex++) {
                    if (cMaxLat < Math.abs(nLatLngs[cIndex].lat - nCurrentLatLng.lat)) {
                        cMaxLat = Math.abs(nLatLngs[cIndex].lat - nCurrentLatLng.lat);
                    }
                    if (cMaxLng < Math.abs(nLatLngs[cIndex].lng - nCurrentLatLng.lng)) {
                        cMaxLng = Math.abs(nLatLngs[cIndex].lng - nCurrentLatLng.lng);
                    }
                }
                var cMaxLatLng = new RLatLng(cMaxLat + nCurrentLatLng.lat, cMaxLng + nCurrentLatLng.lng);
                return cMaxLatLng;
            } else {
                return null;
            }
        } else {
            if (nLatLngs != null && nLatLngs.length > 0) {
                var cArrayLength = nLatLngs.length;
                var cMinLat = nLatLngs[0].lat;
                var cMinLng = nLatLngs[0].lng;
                var cMaxLat = nLatLngs[0].lat;
                var cMaxLng = nLatLngs[0].lng;
                for (var cIndex = 1; cIndex < cArrayLength; cIndex++) {
                    if (cMinLat > nLatLngs[cIndex].lat) {
                        cMinLat = nLatLngs[cIndex].lat;
                    }
                    if (cMinLng > nLatLngs[cIndex].lng) {
                        cMinLng = nLatLngs[cIndex].lng;
                    }
                    if (cMaxLat < nLatLngs[cIndex].lat) {
                        cMaxLat = nLatLngs[cIndex].lat;
                    }
                    if (cMaxLng < nLatLngs[cIndex].lng) {
                        cMaxLng = nLatLngs[cIndex].lng;
                    }
                }
                if (this.isReturnboundsCenter) {
                    this.boundsCenter = new RLatLng((cMaxLat - cMinLat) / 2 + cMinLat, (cMaxLng - cMinLng) / 2 + cMinLng);
                } else {
                    this.setCenter((cMaxLat - cMinLat) / 2 + cMinLat, (cMaxLng - cMinLng) / 2 + cMinLng);
                }
                var cMaxLatLng = new RLatLng(cMaxLat, cMaxLng);
                return cMaxLatLng;
            } else {
                return null;
            }
        }
    }
    //	///从数组中计算出最大经度与最大纬度的，并组合成一点返回
    //	///只与数组集的自身范围来控制大小
    //	this.getMaxLatLngFromArray = function( nLatLngs ){
    //        if( nLatLngs != null && nLatLngs.length > 0 ){
    //            var cArrayLength = nLatLngs.length;
    //            var cMinLat = nLatLngs[0].lat;
    //            var cMinLng = nLatLngs[0].lng;
    //            var cMaxLat = nLatLngs[0].lat;
    //            var cMaxLng = nLatLngs[0].lng;
    //            for( var cIndex = 1;cIndex < cArrayLength ;cIndex++ ){
    //                if( cMinLat >  nLatLngs[ cIndex ].lat ){
    //                    cMinLat = nLatLngs[ cIndex ].lat;
    //                }
    //                if( cMinLng > nLatLngs[ cIndex ].lng ){
    //                    cMinLng = nLatLngs[ cIndex ].lng ;
    //                }
    //                if( cMaxLat <  nLatLngs[ cIndex ].lat ){
    //                    cMaxLat = nLatLngs[ cIndex ].lat;
    //                }
    //                if( cMaxLng < nLatLngs[ cIndex ].lng ){
    //                    cMaxLng = nLatLngs[ cIndex ].lng ;
    //                }
    //            }
    //            if(this.isReturnboundsCenter){
    //                this.boundsCenter=new RLatLng((cMaxLat-cMinLat)/2+cMinLat,(cMaxLng-cMinLng)/2+cMinLng);
    //            }else{
    //                this.setCenter((cMaxLat-cMinLat)/2+cMinLat,(cMaxLng-cMinLng)/2+cMinLng);
    //            }
    //            var cMaxLatLng = new RLatLng( cMaxLat,cMaxLng );
    //            return cMaxLatLng;
    //        }else{
    //            return null;
    //        }
    //	}
    this.getMapType = function() {
        return this.maptype;
    }
    this.getZoomLevels = function() {
        return this.zoomlevels;
    }
    this.getAvailableMaxZoomLevel = function() {
        return this.availableMaxZoomLevel;
    }
    this.calculateAvailableMaxZoomLevel = function(latlng) {
        if (latlng.toString() != 'RLatLng' || this.maptype == 'satellite') {
            return this.scalefactors.length;
        }
        var imgUrls = new Array();
        for (var iLevel = 0; iLevel < this.scalefactors.length; iLevel++) {
            var xabsolute = Math.floor(latlng.lng / this.scalefactors[iLevel]);
            var yabsolute = Math.floor(latlng.lat / this.scalefactors[iLevel]);
            var xdir = Math.floor(xabsolute / this.gridfactors[iLevel]);
            var ydir = Math.floor(yabsolute / this.gridfactors[iLevel]);
            var xfile = xabsolute - xdir * this.gridfactors[iLevel];
            var yfile = yabsolute - ydir * this.gridfactors[iLevel];
            imgUrls[iLevel] = this.mapdb + '/' + this.directorys[iLevel] + '/' + xdir + '/' + ydir + '/' + xfile + '_' + yfile + '.png';
        }
        var tImg = new Image();
        tImg.root = this;
        tImg.urls = imgUrls;
        tImg.iLevel = this.scalefactors.length - 1;
        tImg.onerror = function() {
            this.iLevel--;
            if (this.iLevel < 0) {
                this.root.availableMaxZoomLevel = 0;
                this.root.notify('onMaxlevelUpdated');
                return;
            }
            this.src = this.urls[this.iLevel];
        }
        tImg.onload = function() {
            this.root.availableMaxZoomLevel = this.iLevel;
            this.root.notify('onMaxlevelUpdated');
        }
        tImg.src = imgUrls[imgUrls.length - 1];
    }
    this.calculateAvailableMaxZoomLevel(new RLatLng(this.lat, this.lng));
    this.getSatelliteMaxZoomLevel = function() {
        return this.SatelliteMaxZoomLevel;
    }
    this.calculateSatelliteMaxZoomLevel = function(latlng) {
        var cLat = this.lat;
        var cLng = this.lng;
        if (latlng) {
            if (latlng.toString() == 'RLatLng') {
                cLat = latlng.lat;
                cLng = latlng.lng;
            }
        }
        var xabsolute = Math.floor(cLng / this.scalefactors[this.zoom]);
        var yabsolute = Math.floor(cLat / this.scalefactors[this.zoom]);
        var xdir = Math.floor(xabsolute / this.gridfactors[this.zoom]);
        var ydir = Math.floor(yabsolute / this.gridfactors[this.zoom]);
        var xfile = xabsolute - xdir * this.gridfactors[this.zoom];
        var yfile = yabsolute - ydir * this.gridfactors[this.zoom];
        var imgUrl = this.maproot + '/satellite/' + '/' + this.directorys[this.zoom] + '/' + xdir + '/' + ydir + '/' + xfile + '_' + yfile + '.png';
        var tImg = new Image();
        tImg.root = this;
        tImg.urls = imgUrl;
        tImg.onerror = function() {
            this.root.SatelliteMaxZoomLevel = 0;
            this.root.notify('onSatelliteMaxlevelUpdated');
            return;
        }
        tImg.onload = function() {
            this.root.SatelliteMaxZoomLevel = this.root.zoom;
            this.root.notify('onSatelliteMaxlevelUpdated');
        }
        tImg.src = imgUrl;
    }
    //添加logo
    this.addLogo = function() {
        if (!this.logo) {
            this.logo = new RDiv(this.width - 125, this.height - 18).get();
            this.logoImg = new RImage(0, 0, JS_SERVER + "/rapi/rwidget/rmap/img/twologo2.gif").get();
            this.logo.appendChild(this.logoImg);
            this.logo.style.zIndex = 1000000;
            this.container.appendChild(this.logo);
            this.logo.oncontextmenu = function() {//屏蔽右键
                if (window.event) {
                    window.event.returnValue = false;
                } else {
                    document.oncontextmenu = function(e) { return false; };
                }
            }
            this.logo.root = this;
            this.logo.onresized = function() {
                if (this.root.toolbox) {
                    if (this.root.toolbox.eagleMap) {
                    } else {
                        this.style.left = this.root.width - 125;
                        this.style.top = this.root.height - 18;
                    }
                } else {
                    this.style.left = this.root.width - 125;
                    this.style.top = this.root.height - 18;
                }
            }
            this.addListener(this.logo, 'onresized');
        }
    }
    this.addLogo();
}
function RDepthHandler(offset) {
    this.depth = offset;
    this.toString = function() {
        return 'RDepthHandler';
    }
    this.next = function() {
        this.depth++;
        return this.depth;
    }
}
function RTileLayer(tilewidth, tileheight, scalefactor, directory, gridfactor, mapdb, width, height, key) {
    this.tilewidth = tilewidth;
    this.tileheight = tileheight;
    this.width = width;
    this.height = height;
    this.adjustfactor = 100000;
    this.dbtype = '.png';
    this.div = new RDiv(0, 0, null, null).get();
    this.key = key;
    this.markerdiv = new RDiv(0, 0, null, null).get();
    this.markerdiv.style.zIndex = 10000;
    this.div.appendChild(this.markerdiv);
    this.style = this.div.style;
    if (!scalefactor) { return; }
    this.latscalefactor = scalefactor;
    this.lngscalefactor = scalefactor;
    if (!directory) { return; }
    this.directory = directory;
    if (!gridfactor) { return; }
    this.gridfactor = gridfactor;
    if (!mapdb) { return; }
    this.mapdb = mapdb;
    this.imgs = new Array();
    this.tile = new RDiv(0, 0, null, null).get();
    this.tile.style.zIndex = 1000;
    this.tile.root = this;
    this.div.appendChild(this.tile);
    this.setHybrid = function(ishybrid) {
        this.isHybrid = ishybrid;
    }
    this.getMapDb = function(key) {
        var arrMapDb = ["mapdb0", "mapdb1", "mapdb2"];
        key = key % arrMapDb.length;
        //this.mapdb = arrMapDb[key];
        return arrMapDb[key];
    }
    this.set = function(lat, lng, width, height) {
        this.lat = lat;
        this.lng = lng;
        this.width = width;
        this.height = height;
        var xabsolute = Math.floor((this.lng) / this.lngscalefactor);
        var yabsolute = Math.floor((this.lat) / this.latscalefactor);
        var centerleft = width / 2 - Math.round(((this.lng * this.adjustfactor) % (this.lngscalefactor * this.adjustfactor)) * this.tilewidth / (this.lngscalefactor * this.adjustfactor));
        var centertop = height / 2 - this.tileheight + Math.round(((this.lat * this.adjustfactor) % (this.latscalefactor * this.adjustfactor)) * this.tileheight / (this.latscalefactor * this.adjustfactor));
        var xspan = Math.ceil(width / this.tilewidth / 2);
        var yspan = Math.ceil(height / this.tileheight / 2);
        var count = 0;
        var xgrid = 0;
        while (Math.abs(xgrid) <= xspan) {
            var xdir = Math.floor((xabsolute + xgrid) / this.gridfactor);
            var xfile = xabsolute + xgrid - xdir * this.gridfactor;
            var left = xgrid * this.tilewidth + this.gridfactor;
            var ygrid = 0;
            while (Math.abs(ygrid) <= yspan) {
                var imgname = this.mapdb + '\/' + this.directory + '\/';
                var ydir = Math.floor((yabsolute + ygrid) / (this.gridfactor));
                if (ydir < 0) { ydir += 1; }
                var yfile = yabsolute + ygrid - ydir * this.gridfactor;
                imgname += xdir + '/' + ydir + '/' + xfile + '_' + yfile + this.dbtype;
                //if(imgname.indexOf("1_3") != -1)debugger
                if (imgname.indexOf("mapdb0") != -1)
                    imgname = imgname.replace("mapdb0", this.getMapDb(xfile));
                var left = xgrid * this.tilewidth + centerleft;
                var top = -ygrid * this.tileheight + centertop;
                if (this.isHybrid) {
                    imgname = imgname.replace(/typical/, 'satellite');
                }
                if (this.hasImage(imgname)) {
                    var img = this.hasImage(imgname);
                    img.get().style.left = left;
                    img.get().style.top = top;
                    img.get().rleft = left;
                    img.get().rtop = top;
                    img.get().width = this.tilewidth;
                    img.get().height = this.tileheight;
                    img.onScreen = true;
                } else {
                    var img = new RImage(left, top, imgname);
                    img.key = imgname;
                    img.onScreen = true;
                    this.imgs[this.imgs.length] = img;
                    img.get().root = this;
                    img.get().retrycount = 0;
                    img.get().onerror = function() {
                        if (this.retrycount < 2 && this.onerror != null) {
                            this.width = this.root.tilewidth;
                            this.height = this.root.tileheight;
                            this.retrycount++;
                            this.src = this.src;
                        }
                        else if (this.retrycount == 2 && this.onerror != null) {
                            this.retrycount++;
                            this.width = this.root.tilewidth;
                            this.height = this.root.tileheight;
                            if (this.src.indexOf('satellite') >= 0) {
                                var re = /satellite/;
                                this.src = this.src.replace(re, 'typical');
                                this.root.notify('onsatelliteerror');
                            } else {
                                this.root.notify('ontypicalerror');
                                this.onerror = null;
                                this.src = JS_SERVER + 'rapi/rwidget/rmap/img/maskerr.png';
                            }
                        }
                        else if (this.retrycount > 2 && this.onerror != null) {
                            this.onerror = null;
                            this.src = JS_SERVER + 'rapi/rwidget/rmap/img/maskerr.png';
                            this.root.notify('ontypicalerror');
                            this.width = this.root.tilewidth;
                            this.height = this.root.tileheight;
                        }
                    }
                    img.get().width = this.tilewidth;
                    img.get().height = this.tileheight;
                    img.get().rleft = left; //alert(left);
                    img.get().rtop = top;
                    this.tile.appendChild(img.get());
                }
                if (this.isHybrid) {
                    var re = /satellite/;
                    var secondImgName = imgname.replace(re, 'typical');
                    img.get().rleft = left;
                    img.get().rtop = top;
                    if (this.hasImage(secondImgName)) {
                        var img = this.hasImage(secondImgName);
                        img.get().style.left = left;
                        img.get().style.top = top;
                        img.get().width = this.tilewidth;
                        img.get().height = this.tileheight;
                        if (img.addEventListener) {
                            img.style.opacity = 0.5;
                        } else {
                            img.style.filter = "Chroma(color='#FFFFFF')";
                        }
                        img.onScreen = true;
                        this.tile.appendChild(img.get());
                    } else {
                        var img = new RImage(left, top, secondImgName);
                        if (img.addEventListener) {
                            img.style.opacity = 0.5;
                        } else {
                            img.style.filter = "Chroma(color='#FFFFFF')";
                        }
                        img.key = secondImgName;
                        img.onScreen = true;
                        this.imgs[this.imgs.length] = img;
                        img.get().root = this;
                        img.get().width = this.tilewidth;
                        img.get().height = this.tileheight;
                        this.tile.appendChild(img.get());
                    }
                } else {
                    if (img.addEventListener) {
                        img.style.opacity = 1;
                    } else {
                        img.style.filter = "";
                    }
                }
                if (ygrid == yspan) {
                    ygrid = -1
                } else {
                    if (ygrid >= 0) {
                        ygrid++;
                    } else {
                        ygrid--;
                    }
                }
            }
            if (xgrid == xspan) {
                xgrid = -1
            } else {
                if (xgrid >= 0) {
                    xgrid++;
                } else {
                    xgrid--;
                }
            }
        }
        this.deleteOutScreenImages();
    }
    this.get = function() {
        return this.div;
    }
    this.hide = function() {
        this.div.style.visibility = "hidden";
        this.tile.style.visibility = "hidden";
        this.markerdiv.style.visibility = 'hidden';
    }
    this.show = function() {
        this.style.visibility = "visible";
        this.tile.style.visibility = "visible";
        this.markerdiv.style.visibility = 'visible';
    }
    this.setElementZoom = function(element, zoom) {
        for (var i = 0; i < element.childNodes.length; i++) {
            if (element.childNodes[i].childNodes.length > 1) {
                if (element.childNodes[i].tagName) {
                    this.setElementZoom(element.childNodes[i], zoom);
                }
            } else {
                if (element.childNodes[i].tagName) {
                    if (element.childNodes[i].tagName == 'IMG') {
                        element.childNodes[i].width = Math.ceil(this.tilewidth * zoom);
                        element.childNodes[i].height = Math.ceil(this.tileheight * zoom);
                        var left = this.width / 2 - (this.width / 2 - parseInt(element.childNodes[i].rleft)) * zoom;
                        var top = this.height / 2 - (this.height / 2 - parseInt(element.childNodes[i].rtop)) * zoom;
                        element.childNodes[i].style.left = Math.round(left);
                        element.childNodes[i].style.top = Math.round(top);
                    }
                }
            }
        }
    }
    this.setZoom = function(zoom) {
        if (this.div.style.zoom == '' || this.div.style.zoom) {
            this.style.zoom = zoom;
            this.div.style.left = (this.width * (1 - zoom)) / 2
            this.div.style.top = (this.height * (1 - zoom)) / 2
        } else {
            this.setElementZoom(this.div, zoom);
        }
        this.tempZoom = zoom;
    }
    this.revertZoom = function() { }
    this.addMarkers = function(markers) {
        this.markers = markers;
        for (var i = 0; i < markers.length; i++) {
            this.addMarker(markers[i]);
        }
    }
    this.addMarker = function(marker) {
        var left = 0;
        var top = 0;
        switch (marker.toString()) {
            case "RPoint":
            case "RLabelPoint":
            case "RBalloon":
                var tmp = this.getPixel(marker.lat, marker.lng);
                left = tmp.left;
                top = tmp.top;
                break;
            case "RPath":
            case "RRegion":
                var points = "";
                var x1 = 0;
                var y1 = 0;
                var x2 = 0;
                var y2 = 0;
                if (this.div.addEventListener) {
                    for (var index = 0; index < marker.latlngs.length; index++) {
                        if (index == 0) {
                            x1 = marker.latlngs[index].lat;
                            y1 = marker.latlngs[index].lng;
                            x2 = marker.latlngs[index].lat;
                            y2 = marker.latlngs[index].lng;
                        } else {
                            x1 = (x1 < marker.latlngs[index].lat) ? marker.latlngs[index].lat : x1;
                            y1 = (y1 > marker.latlngs[index].lng) ? marker.latlngs[index].lng : y1;
                            x2 = (x2 > marker.latlngs[index].lat) ? marker.latlngs[index].lat : x2;
                            y2 = (y2 < marker.latlngs[index].lng) ? marker.latlngs[index].lng : y2;
                        }
                    }
                    var pTmp = this.getPixel(x1, y1);
                    x1 = pTmp.left - 3;
                    y1 = pTmp.top - 3;
                    pTmp = this.getPixel(x2, y2);
                    x2 = pTmp.left + 3;
                    y2 = pTmp.top + 3;
                }
                var tmp;
                for (var i = 0; i < marker.latlngs.length; i++) {
                    tmp = this.getPixel(marker.latlngs[i].lat, marker.latlngs[i].lng);
                    if (this.div.addEventListener) {
                        if (i == 0) {
                            points += "M" + (tmp.left - x1) + " " + (tmp.top - y1) + " ";
                        } else {
                            points += "L" + (tmp.left - x1) + "," + (tmp.top - y1) + " ";
                        }
                    } else {
                        points += tmp.left + "," + tmp.top + " ";
                    }
                }
                marker.repaintPolyline();
                if (this.div.addEventListener) {
                    marker.setRegion((x2 - x1), (y2 - y1));
                    marker.stroke.setAttribute("d", points);
                    left = x1;
                    top = y1;
                    marker.polyline.setAttribute("viewBox", "0 0 " + (x2 - x1) + " " + (y2 - y1));
                } else {
                    if (marker.toString() == "RPath") {
                        marker.setCap(marker.unStartCap, marker.unEndCap);
                    }
                    if (marker.polyline.points) {
                        marker.polyline.points.value = points;
                    } else {
                        marker.polyline.points = points;
                    }
                }
                break;
            case 'RRectRegion':
                var tmp1 = this.getPixel(marker.leftbottom.lat, marker.leftbottom.lng);
                var tmp2 = this.getPixel(marker.righttop.lat, marker.righttop.lng);
                var width = Math.abs(tmp2.left - tmp1.left);
                var height = Math.abs(tmp2.top - tmp1.top);
                left = (tmp1.left < tmp2.left) ? tmp1.left : tmp2.left;
                top = (tmp2.top < tmp1.top) ? tmp2.top : tmp1.top;
                if (marker.svg) {
                    marker.rect.setAttribute("width", width);
                    marker.rect.setAttribute("height", height);
                    marker.svg.setAttribute("width", width);
                    marker.svg.setAttribute("height", height);
                    marker.svg.setAttribute("viewBox", "0 0 " + width + " " + height);
                } else {
                    marker.rect.style.width = width;
                    marker.rect.style.height = height;
                }
                break;
            case 'RCircleRegion':
                var tmp1 = this.getPixel(marker.center.lat - marker.radius, marker.center.lng - marker.radius);
                var tmp2 = this.getPixel(marker.center.lat + marker.radius, marker.center.lng + marker.radius);
                var width = Math.abs(tmp2.left - tmp1.left);
                var height = Math.abs(tmp2.top - tmp1.top);
                left = (tmp1.left < tmp2.left) ? tmp1.left : tmp2.left;
                top = (tmp2.top < tmp1.top) ? tmp2.top : tmp1.top;
                if (marker.svg) {
                    marker.oval.setAttribute("cx", Math.round(width / 2));
                    marker.oval.setAttribute("cy", Math.round(height / 2));
                    marker.oval.setAttribute("r", Math.floor(width / 2) - 1);
                    marker.svg.setAttribute("width", width);
                    marker.svg.setAttribute("height", height);
                    marker.svg.setAttribute("viewBox", "0 0 " + width + " " + height);
                } else {
                    marker.oval.style.width = width;
                    marker.oval.style.height = height;
                }
                break;
            default:
                return;
                break;
        }
        marker.div.style.left = left;
        marker.div.style.top = top;
        this.markerdiv.appendChild(marker.div);
    }
    this.getPixel = function(lat, lng) {
        lat = parseFloat(lat);
        lng = parseFloat(lng);
        if (!(lat > -90 && lat < 90) || !(lng > -180 && lng < 180)) {
            window.status = '企图使用非法的经纬度定位地图';
            return;
        }
        var left = this.width / 2 + Math.round((lng - this.lng) / this.lngscalefactor * this.tilewidth);
        var top = this.height / 2 - Math.round((lat - this.lat) / this.latscalefactor * this.tileheight);
        return new RPixel(left, top);
    }
    this.getLatLng = function(left, top) {
        var lng = Math.round((this.lng + (left - this.width / 2) * this.lngscalefactor / this.tilewidth) * 100000) / 100000;
        var lat = Math.round((this.lat - (top - this.height / 2) * this.latscalefactor / this.tileheight) * 100000) / 100000;
        return new RLatLng(lat, lng);
    }
    this.clearMarkers = function() {
        this.markerdiv.innerHTML = '';
    }
    this.clearImages = function() {
        this.tile.innerHTML = '';
        for (var iImg in this.imgs) {
            try {
                if (this.imgs[iImg].get().parentNode) {
                    this.imgs[iImg].get().parentNode.removeChild(this.imgs[iImg].get());
                }
            } catch (e) { }
            this.imgs[iImg].get().onerror = null;
            this.imgs[iImg].get().src = 'about:blank';
            this.imgs[iImg] = null;
        }
        this.imgs = new Array();
    }
    this.stopImages = function() {
        for (var iImg = 0; iImg < this.imgs.length; iImg++) {
            if (!this.imgs[iImg].get().complete) {
                try {
                    if (this.imgs[iImg].get().parentNode) {
                        this.imgs[iImg].get().parentNode.removeChild(this.imgs[iImg].get());
                    }
                } catch (e) { }
                this.imgs[iImg].get().onerror = null;
                this.imgs[iImg].get().src = 'about:blank';
                this.imgs[iImg].key = 'invalid';
                this.imgs[iImg].onScreen = false;
            } else {
                this.imgs[iImg].onScreen = true;
            }
        }
        this.deleteOutScreenImages();
    }
    this.hasImage = function(key) {
        for (var iImg = 0; iImg < this.imgs.length; iImg++) {
            if (this.imgs[iImg].key == key) {
                return this.imgs[iImg];
            }
        }
        return false;
    }
    this.deleteOutScreenImages = function() {
        var tmpImgs = new Array();
        for (var iImg in this.imgs) {
            if (this.imgs[iImg].onScreen) {
                tmpImgs[tmpImgs.length] = this.imgs[iImg];
                this.imgs[iImg].onScreen = false;
            } else {
                if (this.imgs[iImg].get) {
                    try {
                        if (this.imgs[iImg].get().parentNode) {
                            this.imgs[iImg].get().parentNode.removeChild(this.imgs[iImg].get());
                        }
                    } catch (e) { }
                    this.imgs[iImg].get().onerror = null;
                    this.imgs[iImg].get().src = 'about:blank';
                }
            }
            this.imgs[iImg] = null;
        }
        this.imgs = tmpImgs;
        tmpImgs = null;
    }
    this.hideMarkers = function() {
        this.markerdiv.style.visibility = 'hidden';
    }
    this.showMarkers = function() {
        this.markerdiv.style.visibility = 'visible';
    }
    this.setScaleFactor = function(scalefactor) {
        this.scalefactor = scalefactor;
        this.lngscalefactor = scalefactor;
        this.latscalefactor = scalefactor;
    }
    this.ontypicalerror = new Array();
    this.onsatelliteerror = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'ontypicalerror':
                if (listener.ontypicalerror) { this.ontypicalerror[this.ontypicalerror.length] = listener; }
                break;
            case 'onsatelliteerror':
                if (listener.onsatelliteerror) { this.onsatelliteerror[this.onsatelliteerror.length] = listener; }
                break;
            default:
                window.status = this.toString() + '类不存在事件' + estring;
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'ontypicalerror':
                for (var i = 0; i < this.ontypicalerror.length; i++) {
                    if (this.ontypicalerror[i].ontypicalerror) {
                        this.ontypicalerror[i].ontypicalerror();
                    }
                }
                break;
            case 'onsatelliteerror':
                for (var i = 0; i < this.onsatelliteerror.length; i++) {
                    if (this.onsatelliteerror[i].onsatelliteerror) {
                        this.onsatelliteerror[i].onsatelliteerror();
                    }
                }
                break;
            default:
                window.status = this.toString() + '通报了一个未知的事件' + estring;
                break;
        }
    }
}
function RImage(left, top, src) {
    this.img = new Image();
    this.style = this.img.style;
    if (left) { this.style.left = left; }
    if (top) { this.style.top = top; }
    if (src) { this.img.src = src; }
    this.style.position = 'absolute';
    this.style.visibility = 'inherit';
    //this.img.unselectable='on';
    this.get = function() {
        return this.img;
    }
    this.toString = function() {
        return 'RImage';
    }
    this.img.onerror = function() {
        this.onerror = function() {
            this.onerror = null;
            this.src = this.src;
        }
        this.src = this.src;
    }
    this.hide = function() {
        this.style.visibility = 'hidden';
    }
    this.show = function() {
        this.style.visibility = 'visible';
    }
}
function RPixel(left, top) {
    this.left = left;
    this.top = top;
    this.toString = function() {
        return 'RPixel';
    }
}
function RPoint(latlng, zIndex, icon, label, detail, labelpath) {
    this.label = label;
    this.detail = detail;
    this.type = "Point";
    this.latlng = latlng;
    this.lat = latlng.lat;
    this.lng = latlng.lng;
    this.labelpath = JS_SERVER + '/rapi/rwidget/rmap/img';
    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    if (labelpath) {
        this.labelpath = labelpath;
    }
    this.div.style.zIndex = zIndex;
    if (this.detail) {
        var width = this.label.length * 15 + 40;
        if (width < 200) { width = 200; }
        this.div.detail = new RFloatDialog(20, 10, width, this.label, this.detail);
        this.div.detail.get().onmouseover = function() {
            this.depth = this.parentNode.style.zIndex;
            this.parentNode.style.zIndex = 10000;
        }
        this.div.detail.get().onmouseout = function() {
            this.parentNode.style.zIndex = this.depth;
        }
        this.div.detail.style.zIndex = 10000;
        this.div.detail.hide();
        this.div.appendChild(this.div.detail.get());
    }
    if (!icon) {
        var str_color = '#00349A';
        var str_placeholder = '<div style="height:3px;width:100%;font-size:3px"></div>';
        if (labelpath) {
            this.labeldiv = new RDiv(-3, -30, this.label.length * 15 + 40, 17).get();
            str_color = '#ffffff';
            str_placeholder = '<div style="height:4px;width:100%;font-size:4px"></div>';
        } else {
            this.labeldiv = new RDiv(-4, -7, this.label.length * 15 + 40, 17).get();
        }
        this.labeldiv.innerHTML = '<table border=0 cellspacing=0 cellpadding=0><tr><td><img src='
+ this.labelpath
+ '/label1.gif></td><td valign="top" style="background-image:url('
+ this.labelpath
+ '/label2.gif);background-repeat:repeat-x;color:' + str_color + ';font-size:12px;cursor:default" >' + str_placeholder
+ label
+ '</td><td><img src='
+ this.labelpath
+ '/label3.gif></td></tr></table>';
        this.labeldiv.style.zIndex = zIndex;
        this.div.appendChild(this.labeldiv);
        if (this.div.detail) {
            this.labeldiv.onmouseover = function() {
                this.pin = false;
                if (this.parentNode.style.zIndex != 10000) {
                    this.oldIndex = this.parentNode.style.zIndex;
                }
                this.parentNode.style.zIndex = 10000;
                if (!this.parentNode.detail.get().pin) {
                    this.parentNode.detail.get().style.left = 20;
                    this.parentNode.detail.get().style.top = 10;
                }
                this.parentNode.detail.show();
            }
            this.labeldiv.onmouseout = function() {
                if (!this.pin && !this.parentNode.detail.get().pin) {
                    this.parentNode.style.zIndex = this.oldIndex;
                    this.parentNode.detail.hide();
                }
            }
            this.labeldiv.onclick = function() {
                this.pin = true;
                this.parentNode.detail.get().pin = true;
            }
        }
    } else {
        this.img = new RImage(0, 0, icon).get();
        this.img.style.zIndex = zIndex;
        this.img.onload = function() {
            this.style.top = -this.height;
        }
        this.img.style.top = -this.img.height;
        this.div.appendChild(this.img);
        if (this.div.detail) {
            this.img.onmouseover = function() {
                this.pin = false;
                if (this.parentNode.style.zIndex != 10000) {
                    this.depth = this.parentNode.style.zIndex;
                }
                this.parentNode.style.zIndex = 10000;
                if (!this.parentNode.detail.get().pin) {
                    this.parentNode.detail.get().style.left = 20;
                    this.parentNode.detail.get().style.top = 10;
                }
                this.parentNode.detail.show();
            }
            this.img.onclick = function() {
                this.pin = true;
                this.parentNode.detail.get().pin = true;
            }
            this.img.onmouseout = function() {
                this.parentNode.style.zIndex = this.depth;
                if (!this.pin && !this.parentNode.detail.get().pin) {
                    this.parentNode.detail.hide();
                }
            }
        }
    }
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return 'RPoint';
    }
    this.setImg = function(width, height) {
        if (this.img) {
            if (width) {
                this.img.style.width = width;
            }
            if (height) {
                this.img.style.height = height;
            }
        }
    }
    this.setOffset = function(left, top) {
        this.img.onload = null;
        if (left) {
            this.img.style.left = -left;
        } else {
            this.img.style.left = -this.img.width / 2;
        }
        if (top) {
            this.img.style.top = -top;
        } else {
            this.img.style.top = -this.img.height + 7;
        }
    }
    this.showDetail = function() {
        if (this.detail) {
            this.pin = true;
            this.div.detail.get().pin = true;
            this.div.detail.show();
        }
    }
    this.hideDetail = function() {
        if (this.detail) {
            this.pin = false;
            this.div.detail.get().pin = false;
            this.div.detail.hide();
        }
    }
    this.getRDiv = function() {
        return this.div;
    }
    this.destroy = function() {
        if (this.labeldiv) {
            this.labeldiv = null;
        }
        if (this.div) {
            if (this.div.parentNode) {
                this.div.parentNode.removeChild(this.div);
            }
            if (this.div.detail) {
                this.div.detail = null;
            }
        }
        this.div = null;
        this.toString = function() { return null; };
    }
}
function RFloatDialog(left, top, width, title, content) {
    this.title = title;
    this.content = content;
    this.left = left;
    this.top = top;
    this.width = width;
    this.div = new RDiv(this.left, this.top, width, null).get();
    this.div.style.visibility = 'hidden';
    this.style = this.div.style;
    this.contentdiv = new RDiv(0, 0, width, null).get();
    this.toString = function() {
        return 'RFloatDialog';
    }
    this.setContentHTML = function(title, content) {
        this.contentdiv.innerHTML = '<table style="border:1px solid #A3A3A3" bgcolor="#FFFFFF" cellspacing="0" cellpadding="0" width=' + this.width + '>'
+ '<tr><td>'
+ '<table border="0" cellspacing="2" cellpadding="0" width="100%"><tr><td bgcolor="#FDE5B7">'
+ '<table border="0"  cellspacing="2" cellpadding="0" align="left" width="100%"><tr>'
+ '<td align="left" height="20" width="25"></td>'
+ '<td  valign="top" align="left" style="font-size:12px;color:#000000">&nbsp;<b>' + title + '&nbsp;</b></td>'
+ '</tr></table>'
+ '</td></tr>'
+ '<tr><td bgcolor="#FFFEF2">'
+ '<table border="0" cellpadding="0" cellspacing="1" align="left" width="100%">'
+ '<tr><td valign="top" align="left" style="font-size:12px;color:#000000">' + content + '</td></tr>'
+ '</table></td></tr>'
+ '</table></td></tr>'
+ '</table>';
    }
    this.setContentHTML(this.title, this.content);
    this.div.appendChild(this.contentdiv);
    this.div.pin = false;
    this.div.onoff = true;
    this.close = document.createElement("a");
    this.close.style.cursor = "pointer";
    this.close.style.color = "#FFFFFF";
    this.close.style.left = this.width - 25;
    this.close.style.top = 7;
    this.close.style.position = "absolute";
    this.close.innerHTML = '<img src="' + JS_SERVER + '/rapi/rwidget/rfloatdialog/img/close.gif">';
    this.close.onclick = function() {
        this.parentNode.pin = false;
        this.parentNode.style.visibility = "hidden";
    }
    //	this.onoff=document.createElement("a");
    //	this.onoff.style.cursor="pointer";
    //	this.onoff.style.color="#FFFFFF";
    //	this.onoff.style.left=15;
    //	this.onoff.style.top=0;
    //	this.onoff.style.position="absolute";
    //	this.onoff.innerHTML='<span style="font-family:Webdings;font-size:12px">5</span>';
    //	this.onoff.onmouseout=function(){
    //		this.style.color="#FFFFFF";
    //	}
    //	this.onoff.onmouseover=function(){
    //		this.style.color="#0000FF";
    //	}
    //	this.onoff.onclick=function(){
    //		if(this.parentNode.onoff){
    //			this.innerHTML='<span style="font-family:Webdings;font-size:12px">6</span>';
    //			this.parentNode.style.height=20;
    //			this.parentNode.style.overflow="hidden";
    //		}else{
    //			this.innerHTML='<span style="font-family:Webdings;font-size:12px">5</span>';
    //			this.parentNode.style.overflow="visible";
    //		}
    //		this.parentNode.onoff=!this.parentNode.onoff;
    //	}
    this.div.appendChild(this.close);
    //	this.div.appendChild(this.onoff);
    this.div.onmousedown = function() {
        this.style.cursor = "default";
        this.leftorigin = parseInt(this.style.left, 10);
        this.toporigin = parseInt(this.style.top, 10);
        this.xorigin = event.clientX;
        this.yorigin = event.clientY;
        this.drag = true;
    }
    this.div.onmouseup = function() {
        this.style.cursor = "default";
        this.drag = false;
    }
    this.div.onmousemove = function() {
        if (false) {
            this.style.cursor = "move";
            this.style.left = this.leftorigin + event.clientX - this.xorigin;
            this.style.top = this.toporigin + event.clientY - this.yorigin;
        }
    }
    this.div.onmouseout = function() {
        this.style.cursor = "default";
        this.drag = false;
    }
    this.setTitle = function(title) {
        this.title = title;
        this.setContentHTML(this.title, this.content);
    }
    this.setContent = function(content) {
        this.content = content;
        this.setContentHTML(this.title, this.content);
    }
    this.get = function() {
        return this.div;
    }
    this.show = function() {
        this.div.style.visibility = 'visible';
    }
    this.hide = function() {
        this.div.style.visibility = 'hidden';
    }
}
function RPath(latlngs, color, weight, opacity) {
    this.type = "Path";
    this.color = color;
    this.weight = weight;
    this.latlngs = latlngs;
    this.polyline = null;
    this.stroke = null;
    this.div = new RDiv(0, 0, null, null).get();
    this.repaintPolyline = function(isClosed, fillColor) {
        if (this.polyline) {
            this.polyline.parentNode.removeChild(this.polyline);
        }
        if (this.div.addEventListener) {
            this.polyline = document.createElementNS(SVG_URL, "svg");
            this.polyline.setAttribute("version", "1.1");
            this.polyline.setAttribute("overflow", "visible");
            this.stroke = document.createElementNS(SVG_URL, "path")
            this.stroke.setAttribute("stroke", this.color);
            this.stroke.setAttribute("stroke-width", this.weight);
            if (opacity) {
                this.stroke.setAttribute("stroke-opacity", opacity);
            } else {
                this.stroke.setAttribute("stroke-opacity", 1);
            }
            if (!isClosed) {
                this.stroke.setAttribute("stroke-linecap", "round");
                this.stroke.setAttribute("stroke-linejoin", "round");
                this.stroke.setAttribute("fill", "none");
            } else {
                this.stroke.setAttribute("stroke-linecap", "square");
                this.stroke.setAttribute("stroke-linejoin", "miter");
                this.stroke.setAttribute("fill", fillColor);
                this.stroke.setAttribute("fill-opacity", 0.6);
            }
            this.polyline.appendChild(this.stroke);
        } else {
            this.polyline = document.createElement("v:polyline");
            this.polyline.unselectable = 'on';
            this.style = this.polyline.style;
            this.polyline.strokecolor = this.color;
            this.polyline.strokeweight = this.weight;
            this.polyline.fill = false;
            this.polyline.filled = false;
            this.stroke = document.createElement("v:stroke");
            this.stroke.joinstyle = "round";
            this.stroke.startcap = "round";
            if (opacity) {
                this.stroke.opacity = opacity;
            } else {
                this.stroke.opacity = 1.0;
            }
            if (!isClosed) {
                this.stroke.startarrow = "diamond";
                this.stroke.endarrow = "classic";
                this.stroke.fill = false;
            } else {
                this.stroke.startarrow = '';
                this.stroke.endarrow = '';
                this.polyline.fill = true;
                this.polyline.filled = true;
                this.polyline.fillcolor = fillColor;
                this.polyline.style.filter = 'alpha(opacity=60)';
            }
        }
        this.polyline.appendChild(this.stroke);
        this.div.appendChild(this.polyline);
    }
    this.setCap = function(unStartCap, unEndCap) {
        if (!this.div.addEventListener) {
            if (unStartCap) {
                this.stroke.startarrow = "none";
            } else {
                this.stroke.startarrow = "diamond";
            }
            if (unEndCap) {
                this.stroke.endarrow = "none";
            } else {
                this.stroke.endarrow = "classic";
            }
        }
    }
    this.setRegion = function(width, height) {
        if (this.div.addEventListener) {
            this.polyline.setAttribute("width", width);
            this.polyline.setAttribute("height", height);
        }
    }
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return 'RPath';
    }
    this.destroy = function() {
        if (this.div) {
            this.div.innerHTML = '';
            if (this.div.parentNode) {
                this.div.parentNode.removeChild(this.div);
            }
            this.div = null;
            this.type = "Path";
            this.color = null;
            this.latlngs = null;
            this.polyline = null;
            this.setCap = null;
            this.repaintPolyline = null;
            this.stroke = null;
        }
        this.toString = function() { return 'DestroyedPathMarker' };
    }
}
function REmbed(left, top, src, width, height) {
    this.embed = document.createElement('Embed');
    this.style = this.embed.style;
    this.style.position = 'absolute';
    this.style.visibility = 'inherit';
    //	this.style.left=left;
    //	this.style.top=top;
    this.embed.src = src;
    this.embed.quality = 'high';
    this.embed.wmode = "transparent"
    this.embed.allowScriptAccess = 'sameDomain';
    //	this.embed.pluginspage="http://www.adobe.com/svg/viewer/install/";
    if (width) {
        this.embed.width = width;
    }
    if (height) {
        this.embed.height = height;
    }
    this.setRegion = function(sWidth, sHeight) {
        this.embed.width = width;
        this.embed.height = height;
    }
    this.toString = function() {
        return 'REmbed';
    }
    this.get = function() {
        return this.embed;
    }
}
function RRegion(latlngs, color, fillcolor, weight) {
    this.type = "Region";
    this.latlngs = latlngs;
    this.latlngs[this.latlngs.length] = latlngs[0];
    this.color = color;
    this.fillcolor = fillcolor;
    this.weight = weight;
    this.path = new RPath(latlngs, this.color, this.weight);
    this.div = this.path.get();
    this.repaintPolyline = function() {
        this.path.repaintPolyline(true, fillcolor);
        this.polyline = this.path.polyline;
        this.stroke = this.path.stroke;
    }
    this.setRegion = function(width, height) {
        if (this.div.addEventListener) {
            this.path.setRegion(width, height);
        }
    }
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return 'RRegion';
    }
    this.destroy = function() {
        if (this.div) {
            if (this.div.parentNode) {
                this.div.parentNode.removeChild(this.div);
            }
            this.div = null;
            this.path.destroy();
            this.path = null;
            this.polyline = null;
            this.stroke = null;
            this.latlngs = null;
        }
        this.toString = function() { return null; };
    }
}
function RLatLng(lat, lng) {
    this.toString = function() {
        return 'RLatLng';
    }
    lat = Math.round(lat * 100000) / 100000;
    lng = Math.round(lng * 100000) / 100000;
    if (lat >= -90 && lat <= 90) {
        this.lat = lat;
    } else {
        window.status = '试图使用纬度' + lat + '建立非法的' + this.toString() + '对象';
        return;
    }
    if (lng >= -180 && lng <= 180) {
        this.lng = lng;
    } else {
        window.status = '试图使用经度' + lng + '建立非法的' + this.toString() + '对象';
        return;
    }
}
function RToolBox(maplet, align, tooldb) {
    this.maplet = maplet;
    this.tooldb = tooldb;
    this.align = align;
    this.tools = new Array();
    this.left = this.maplet.left;
    this.top = this.maplet.top;
    this.div = new RDiv(this.left, this.top, null, null).get();
    this.div.style.zIndex = 1000;
    if (this.maplet.get().parentNode) {
        this.maplet.get().appendChild(this.div);
    } else {
        window.status = 'RToolBox必须在Map对象成为可视元素后再添加';
        return;
    }
    this.style = this.div.style;
    this.div.maplet = this.maplet;
    switch (align) {
        case "0":
        case 0:
        case "left":
            this.align = 0;
            this.style.left = parseInt(this.maplet.container.style.left, 10);
            this.style.top = parseInt(this.maplet.container.style.top, 10);
            break;
        case "1":
        case 1:
        case "top":
            this.align = 1;
            this.style.left = this.maplet.width - 10;
            this.style.top = 10;
            break;
        case "2":
        case 2:
        case "bottom":
            this.align = 2;
            this.style.left = this.maplet.width - 10;
            this.style.top = this.maplet.height - 100;
            break;
        case "3":
        case 3:
        case "right":
            this.align = 3;
            this.style.left = this.maplet.width - 100;
            this.style.top = 10;
            break;
        default:
            this.align = 0;
            break;
    }
    this.addZoom = function() {
        if (this.east) {
            this.zoomtop = 80;
            this.zoomleft = 30;
        } else {
            this.zoomtop = 10;
            this.zoomleft = 10;
        }
        this.comeback = new RImage(this.zoomleft, this.zoomtop, this.tooldb + 'reset.gif').get();
        this.comeback.style.zIndex = 10000;
        this.comeback.title = "按此初始化";
        this.comeback.style.cursor = 'pointer';
        this.zoomin = new RImage(this.zoomleft, this.zoomtop + 20, this.tooldb + 'zoomin.gif').get();
        this.zoomin.style.zIndex = 10000;
        this.zoomin.title = "按此放大";
        this.zoomin.style.cursor = 'pointer';
        this.zoomout = new RImage(this.zoomleft, this.zoomtop + 40, this.tooldb + 'zoomout.gif').get();
        this.zoomout.title = '按此缩小';
        this.zoomout.style.zIndex = 10000;
        this.zoomout.style.cursor = 'pointer';
        this.comeback.onclick = function() {
            this.parentNode.maplet.comeback();
        }
        this.zoomin.onclick = function() {
            this.parentNode.maplet.zoomIn();
        }
        this.zoomout.onclick = function() {
            this.parentNode.maplet.zoomOut();
        }
        this.div.appendChild(this.comeback);
        this.div.appendChild(this.zoomin);
        this.div.appendChild(this.zoomout);
    }
    this.addZoomBar = function() {
        this.stepHeight = 9;
        this.zoomin = new RImage(30, 71, this.tooldb + 'zoomin.gif').get();
        this.zoomin.title = '按此放大';
        this.zoomin.style.zIndex = 10000;
        //		this.zoomin.style.display="none";
        this.zoomin.style.cursor = 'pointer';
        this.zoomcells = new Array();
        this.zoomtips = new Array();
        this.zoomcellsDiv = new RDiv(33, 95).get();
        for (var iLevel = 0; iLevel < this.maplet.getZoomLevels(); iLevel++) {
            var zoomcell = new RImage(0, 0 + Math.abs(this.maplet.getZoomLevels() - iLevel - 2) * this.stepHeight, this.tooldb + 'zoomcell.gif').get();
            //        for(var iLevel=0;iLevel<this.maplet.getZoomLevels();iLevel++){
            //			var zoomcell=new RImage(0,0+iLevel*this.stepHeight,this.tooldb+'zoomcell.gif').get();
            zoomcell.key = iLevel + 1;
            if (zoomcell.key == 16) break;
            zoomcell.root = this;
            zoomcell.title = '第' + (zoomcell.key) + '级';
            zoomcell.style.zIndex = 9000;
            zoomcell.onclick = function() {
                this.root.maplet.setZoomLevel(this.key - 1);
            }
            zoomcell.onmouseover = function() {
                if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                    for (var i = 0; i < this.root.zoomtips.length; i++) {
                        this.root.zoomtips[i].style.display = "block";
                    }
                }
            }
            zoomcell.onmouseout = function() {
                if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                    for (var i = 0; i < this.root.zoomtips.length; i++) {
                        this.root.zoomtips[i].style.display = "none";
                    }
                }
            }
            zoomcell.oncontextmenu = function() {//屏蔽右键
                if (window.event) {
                    window.event.returnValue = false;
                } else {
                    document.oncontextmenu = function(e) { return false; };
                }
            }
            this.zoomcells.push(zoomcell);
            switch (iLevel) {
                case 0:
                    var zoomtip = new RImage(14, -3 + Math.abs(iLevel - this.maplet.getAvailableMaxZoomLevel() + 1) * this.stepHeight, this.tooldb + 'country.gif').get();
                    zoomtip.root = this;
                    zoomtip.style.zIndex = 9000;
                    zoomtip.style.display = "none";
                    zoomtip.grade = iLevel;
                    this.zoomtips.push(zoomtip);
                    break;
                case 3:
                    var zoomtip = new RImage(14, -3 + Math.abs(iLevel - this.maplet.getAvailableMaxZoomLevel() + 1) * this.stepHeight, this.tooldb + 'province.gif').get();
                    zoomtip.root = this;
                    zoomtip.style.zIndex = 9000;
                    zoomtip.style.display = "none";
                    zoomtip.grade = iLevel;
                    this.zoomtips.push(zoomtip);
                    break;
                case 8:
                    var zoomtip = new RImage(14, -3 + Math.abs(iLevel - this.maplet.getAvailableMaxZoomLevel() + 1) * this.stepHeight, this.tooldb + 'city.gif').get();
                    zoomtip.root = this;
                    zoomtip.style.zIndex = 9000;
                    zoomtip.style.display = "none";
                    zoomtip.grade = iLevel;
                    this.zoomtips.push(zoomtip);
                    break;
                case 10:
                    var zoomtip = new RImage(14, -3 + Math.abs(iLevel - this.maplet.getAvailableMaxZoomLevel() + 1) * this.stepHeight, this.tooldb + 'district.gif').get();
                    zoomtip.root = this;
                    zoomtip.style.zIndex = 9000;
                    zoomtip.style.display = "none";
                    zoomtip.grade = iLevel;
                    this.zoomtips.push(zoomtip);
                    break;
                case 13:
                    var zoomtip = new RImage(14, -3 + Math.abs(iLevel - this.maplet.getAvailableMaxZoomLevel() + 1) * this.stepHeight, this.tooldb + 'street.gif').get();
                    zoomtip.root = this;
                    zoomtip.style.zIndex = 9000;
                    zoomtip.style.display = "none";
                    zoomtip.grade = iLevel;
                    this.zoomtips.push(zoomtip);
                    break;
                default:
                    break;
            }
        }
        this.zoomout = new RImage(30, this.maplet.zoomlevels * this.stepHeight + 92, this.tooldb + 'zoomout.gif').get();
        this.zoomout.title = '按此缩小';
        this.zoomout.style.zIndex = 10000;
        this.zoomout.style.cursor = 'pointer';
        //		this.zoomout.style.display="none";
        var slidertop = Math.ceil(95 + (this.maplet.getAvailableMaxZoomLevel() - this.maplet.zoom - 1) * this.stepHeight);
        this.slider = new RImage(30, slidertop, this.tooldb + 'slider.gif').get();
        this.slider.style.zIndex = 10000;
        this.slider.style.cursor = 'pointer';
        this.zoomin.root = this;
        this.zoomout.root = this;
        this.slider.root = this;
        this.zoomin.onclick = function() {
            this.parentNode.maplet.zoomIn();
        }
        this.zoomin.onmouseover = function() {
            if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                for (var i = 0; i < this.root.zoomtips.length; i++) {
                    this.root.zoomtips[i].style.display = "block";
                }
            }
        }
        this.zoomin.onmouseout = function() {
            if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                for (var i = 0; i < this.root.zoomtips.length; i++) {
                    this.root.zoomtips[i].style.display = "none";
                }
            }
        }
        this.zoomin.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.zoomout.onclick = function() {
            this.parentNode.maplet.zoomOut();
        }
        this.zoomout.onmouseover = function() {
            if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                for (var i = 0; i < this.root.zoomtips.length; i++) {
                    this.root.zoomtips[i].style.display = "block";
                }
            }
        }
        this.zoomout.onmouseout = function() {
            if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                for (var i = 0; i < this.root.zoomtips.length; i++) {
                    this.root.zoomtips[i].style.display = "none";
                }
            }
        }
        this.zoomout.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.slider.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.slider.onmouseover = function() {
            if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                for (var i = 0; i < this.root.zoomtips.length; i++) {
                    this.root.zoomtips[i].style.display = "block";
                }
            }
        }
        this.slider.onmouseout = function() {
            if (this.root.zoomtips && this.root.zoomtips.length > 0) {
                for (var i = 0; i < this.root.zoomtips.length; i++) {
                    this.root.zoomtips[i].style.display = "none";
                }
            }
        }
        this.slider.onmousedown = function() {
            this.drag = true;
            this.yoffset = parseInt(this.style.top, 10) - event.clientY;
        }
        this.slider.onmouseup = function() {
            this.drag = false;
        }
        this.slider.ondrag = function() {
            if (this.drag) {
                if ((event.clientY + this.yoffset) > 88 && (event.clientY + this.yoffset) < 90 + this.root.stepHeight * (this.root.maplet.getAvailableMaxZoomLevel() - 1)) {
                    this.style.top = Math.round((event.clientY + this.yoffset) / this.root.stepHeight) * this.root.stepHeight;
                } else if ((event.clientY + this.yoffset) > 90 + this.root.stepHeight * (this.root.maplet.getAvailableMaxZoomLevel() - 1)) {
                    this.setZoomLevel(0);
                } else if ((event.clientY + this.yoffset) < 90) {
                    this.setZoomLevel(this.root.maplet.getAvailableMaxZoomLevel());
                }
            }
        }
        this.slider.ondragend = function() {
            this.root.maplet.setZoomLevel(this.root.maplet.getAvailableMaxZoomLevel() - Math.round((parseInt(this.style.top, 10) - 90) / this.root.stepHeight));
        }
        this.slider.setZoomLevel = function(zoom) {
            this.style.top = 90 + (this.root.maplet.getAvailableMaxZoomLevel() - zoom) * this.root.stepHeight;
        }
        this.slider.onzoomchanged = function() {
            this.setZoomLevel(this.root.maplet.zoom);
        }
        this.slider.onMaxlevelUpdated = function() {
            var maxLevel = this.root.maplet.getAvailableMaxZoomLevel();
            this.root.zoomcellsDiv.style.top = 98 - this.root.stepHeight * (15 - maxLevel); ///////////
            for (var iLevel = 0; iLevel < this.root.zoomcells.length; iLevel++) {
                if (iLevel <= maxLevel) {
                    this.root.zoomcells[iLevel].style.visibility = 'visible';
                } else {
                    this.root.zoomcells[iLevel].style.visibility = 'hidden';
                }
            }
            for (var i = 0; i < this.root.zoomtips.length; i++) {
                if (this.root.zoomtips[i].grade > maxLevel) {
                    this.root.zoomtips[i].style.visibility = 'hidden';
                } else {
                    this.root.zoomtips[i].style.visibility = 'visible';
                }
            }
            this.root.zoomout.style.top = (maxLevel + 1) * this.root.stepHeight + 92;
            this.style.top = Math.ceil(90 + (this.root.maplet.getAvailableMaxZoomLevel() - this.root.maplet.zoom) * this.root.stepHeight);
        }
        this.maplet.addListener(this.slider, 'onzoomchanged');
        this.maplet.addListener(this.slider, 'onMaxlevelUpdated');
        this.div.appendChild(this.zoomin);
        for (var iCell = 0; iCell < this.zoomcells.length; iCell++) {
            this.zoomcellsDiv.appendChild(this.zoomcells[iCell]);
            //////////this.div.appendChild(this.zoomcells[iCell]);
        }
        for (var i = 0; i < this.zoomtips.length; i++) {
            this.zoomcellsDiv.appendChild(this.zoomtips[i]);
        }
        this.zoomcellsDiv.style.top = 98 - this.stepHeight * (15 - this.maplet.getAvailableMaxZoomLevel()); ///////////
        this.div.appendChild(this.zoomcellsDiv); /////////
        this.div.appendChild(this.zoomout);
        this.div.appendChild(this.slider);
    }
    this.addPan = function() {
        this.east = new RImage(50, 30, this.tooldb + 'east.gif').get();
        this.east.title = '向东平移';
        this.east.style.zIndex = 10000;
        this.east.style.cursor = 'pointer';
        this.south = new RImage(30, 50, this.tooldb + 'south.gif').get();
        this.south.title = '向南平移';
        this.south.style.zIndex = 10000;
        this.south.style.cursor = 'pointer';
        this.west = new RImage(10, 30, this.tooldb + 'west.gif').get();
        this.west.title = '向西平移';
        this.west.style.zIndex = 10000;
        this.west.style.cursor = 'pointer';
        this.north = new RImage(30, 10, this.tooldb + 'north.gif').get();
        this.north.title = '向北平移';
        this.north.style.zIndex = 10000;
        this.north.style.cursor = 'pointer';
        this.reset = new RImage(30, 30, this.tooldb + 'reset.gif').get();
        this.reset.title = '重置地图到初始状态';
        this.reset.style.zIndex = 10000;
        this.reset.style.cursor = 'pointer';
        this.east.onclick = function() {
            this.parentNode.maplet.panEast();
        }
        this.east.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.south.onclick = function() {
            this.parentNode.maplet.panSouth();
        }
        this.south.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.west.onclick = function() {
            this.parentNode.maplet.panWest();
        }
        this.west.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.north.onclick = function() {
            this.parentNode.maplet.panNorth();
        }
        this.north.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.reset.onclick = function() {
            this.parentNode.maplet.dynSmoothMove(this.parentNode.maplet.initlat, this.parentNode.maplet.initlng, this.parentNode.maplet.initzoom);
        }
        this.reset.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.div.appendChild(this.east);
        this.div.appendChild(this.south);
        this.div.appendChild(this.west);
        this.div.appendChild(this.north);
        this.div.appendChild(this.reset);
    }
    this.addEagleMap = function(width, height) {
        this.eagleMap = new REagleMap(width, height, this.maplet, this.tooldb, this.maplet.maproot);
        this.maplet.container.appendChild(this.eagleMap.get());
    }
    this.addCross = function() {
        this.cross = new RImage(this.maplet.width / 2 - 31, this.maplet.height / 2 - 22, this.tooldb + 'cross.gif').get();
        this.cross.width = 63;
        this.cross.height = 45;
        if (!this.cross.addEventListener) {
            this.cross.style.filter = "alpha(opacity=70)";
        } else {
            this.cross.style.opacity = 0.7;
        }
        this.maplet.getMaskLayer().appendChild(this.cross);
    }
    this.addMapType = function() {
        this.typical = new RImage(100, 20, this.tooldb + '/typical.gif').get();
        this.typical.title = '普通地图';
        this.typical.style.zIndex = 10000;
        this.satellite = new RImage(200, 20, this.tooldb + '/satellite.gif').get();
        this.satellite.title = '卫星地图';
        this.satellite.style.zIndex = 10000;
        this.hybrid = new RImage(300, 20, this.tooldb + '/hybrid.gif').get();
        this.hybrid.title = '叠加地图';
        this.hybrid.style.zIndex = 10000;
        this.typical.onclick = function() {
            this.parentNode.maplet.setMapType('typical');
        }
        this.satellite.onclick = function() {
            this.parentNode.maplet.setMapType('satellite');
        }
        this.hybrid.onclick = function() {
            this.parentNode.maplet.setMapType('hybrid');
        }
        this.div.appendChild(this.typical);
        this.div.appendChild(this.satellite);
        this.div.appendChild(this.hybrid);
    }
    // 添加动态非图片标尺
    this.addScale = function() {
        this.scale = new RDiv(15, this.maplet.height - 25, 120, 20).get();
        this.scale.style.zIndex = 10000;
        var ScaleInfo = this.CountScaleLength();
        var scale_length = ScaleInfo[0];
        var scale_unit = ScaleInfo[2];
        this.scale.innerHTML = '<div style="width:'
+ scale_length
+ ' ;filter:glow(color=#FFFFFF,strength=2);" align="center" cellspacing="2"><b>'
+ scale_unit
+ '</b></div><table width="'
+ scale_length
+ '" height=10 cellspacing="2" cellpadding="0" style="filter:glow(color=#FFFFFF,strength=2);border-Left:1px solid #000000;border-right:1px solid #000000;border-bottom:3px solid #000000"><tr><td align="center"></td></tr></table>';
        this.maplet.getMaskLayer().appendChild(this.scale);
        this.scalemaplistener = new Object();
        this.scalemaplistener.root = this;
        this.scalemaplistener.onzoomchanged = function() {
            var ScaleInfo = this.root.CountScaleLength();
            var scale_length_l = ScaleInfo[0];
            var scale_unit_u = ScaleInfo[2];
            this.root.scale.innerHTML = '<div style="width:'
+ scale_length + ' ;filter:glow(color=#FFFFFF,strength=2);" align="center" cellspacing="2"><b>'
+ scale_unit_u
+ '</b></div><table width="'
+ scale_length_l
+ '" height=10 cellspacing="2" cellpadding="0" style="filter:glow(color=#FFFFFF,strength=2);border-Left:1px solid #000000;border-right:1px solid #000000;border-bottom:3px solid #000000"><tr><td align="center"></td></tr></table>';
        }
        this.maplet.addListener(this.scalemaplistener, 'onzoomchanged');
    }
    // 计算比例尺长度
    this.CountScaleLength = function() {
        var zoom = this.maplet.zoom;
        var PIC_PIX_COUNT = 256;
        var MAX_PIX_COUNT = 100;
        var multiple = 1000;
        var VALUES = new Array(1000, 500, 200, 100, 50, 20, 10, 5, 2, 1);
        var M_PER_MAX_PIX = Math.round(this.maplet.scalefactors[zoom] * METERS_PER_DEGREE / PIC_PIX_COUNT * MAX_PIX_COUNT);
        if (M_PER_MAX_PIX < multiple) {
            multiple = 1;
        } else {
            M_PER_MAX_PIX /= multiple;
        }
        var to_show_value = 0;
        for (var index = 0; index < VALUES.length; index++) {
            if (M_PER_MAX_PIX >= VALUES[index]) {
                to_show_value = VALUES[index];
                break;
            }
        }
        var scale_length = MAX_PIX_COUNT * (to_show_value / M_PER_MAX_PIX);
        var scale_unit = to_show_value + (multiple == 1 ? "米" : "公里");
        var scale_info = new Array(scale_length, to_show_value, scale_unit, multiple);
        return scale_info;
    }
    // 添加图片标尺
    this.addImageScale = function(initzoom) {
        this.ImageScale = new RImage(0, this.maplet.height - 10, JS_SERVER
+ "/rapi/rwidget/rmap/toolbox/scale/" + (initzoom) + ".gif").get();
        this.ImageScale.style.zIndex = 1000;
        this.maplet.container.appendChild(this.ImageScale);
        this.ImageScale.oncontextmenu = function() {//屏蔽右键
            if (window.event) {
                window.event.returnValue = false;
            } else {
                document.oncontextmenu = function(e) { return false; };
            }
        }
        this.scalemaplistener = new Object();
        this.scalemaplistener.root = this;
        this.scalemaplistener.onzoomchanged = function() {
            this.root.ImageScale.src = JS_SERVER + "/rapi/rwidget/rmap/toolbox/scale/"
+ (this.root.maplet.zoom) + '.gif';
        }
        this.maplet.addListener(this.scalemaplistener, 'onzoomchanged');
    }
    this.addCopyright = function(width, height) {
        ////	    //文字滤镜实现
        ////		this.copyright=new RDiv(this.maplet.width-width-115, this.maplet.height-18,120,23).get();
        ////		this.copyright.style.color='#000000';
        ////		if(!this.copyright.addEventListener){
        ////	        this.copyright.style.filter='glow(color=#ffffff,strength=2)';
        ////	    }
        ////		this.copyright.innerHTML='&nbsp;&copy;瑞图万方&nbsp;&copy;道道通';
        ////		this.copyright.style.zIndex=10000;
        //		//图片实现
        //		this.copyright=new RDiv(this.maplet.width-width-125, this.maplet.height-18).get();
        //		this.copyright.id = "dfd";
        //		this.copyrightImg = new RImage(0,0,JS_SERVER+"/rapi/rwidget//rmap/img/twologo2.gif").get();
        //		this.copyright.appendChild(this.copyrightImg);
        //		this.copyright.style.zIndex=10000;
        //
        //		this.maplet.container.appendChild(this.copyright);
        //
        //		this.copyright.oncontextmenu=function(){//屏蔽右键
        //	        if(window.event){
        //	            window.event.returnValue=false;
        //	        }else{
        //	            document.oncontextmenu=function(e){return false;};
        //	        }
        //	    }
        ////	    this.copyRightlistener=new Object();
        ////	    this.copyRightlistener.root=this;
        ////	    this.copyRightlistener.onresized=function(){
        ////	        this.root.copyright.style.top=this.root.maplet.height-18;
        ////	    }
        ////	    this.maplet.addListener(this.copyRightlistener,'onresized');
    }
    this.addRectZoominTool = function(tool) {
        tool.setMaplet(this.maplet);
    }
    this.onresized = function() {
        if (this.cross) {
            this.cross.style.left = this.maplet.width / 2 - 31;
            this.cross.style.top = this.maplet.height / 2 - 22;
        }
        if (this.ImageScale) {
            this.ImageScale.style.top = this.maplet.height - 10;
        }
    }
    this.maplet.addListener(this, 'onresized');
    this.hide = function() {
        this.div.style.visibility = 'hidden';
    }
    this.show = function() {
        this.div.style.visibility = 'visible';
    }
    this.toString = function() {
        return 'RToolBox';
    }
    this.addTool = function(tool) {
        tool.setMaplet(this.maplet);
        this.tools[this.tools.length] = tool;
        this.toollistener = new Object();
        this.toollistener.root = this;
        this.toollistener.tool = tool;
        this.toollistener.onturnon = function() {
            this.root.rturnoffAllOtherTools(this.tool);
            if (!this.tool.isKeepOtherMarker) {
                this.root.clearAllOtherTools(this.tool);
            }
        }
        tool.addListener(this.toollistener, 'onturnon');
        this.toollistener.onturnoff = function() {
            if (this.tool.tool.id != 'MapmoveTool') {
                this.root.turnonMapmoveTool(this.tool);
            }
        }
        tool.addListener(this.toollistener, 'onturnoff');
    }
    this.turnonMapmoveTool = function(tool) {
        var isAllToolTurnoff = true;
        var mapmoveTool = null;
        for (var iTool = 0; iTool < this.tools.length; iTool++) {
            if (this.tools[iTool].tool.id != 'MapmoveTool') {
                if (this.tools[iTool].isLock == false) {
                    isAllToolTurnoff = false;
                }
            } else {
                mapmoveTool = this.tools[iTool];
            }
        }
        if (mapmoveTool && isAllToolTurnoff == true) {
            mapmoveTool.turnon();
        }
    }
    this.rturnoffAllOtherTools = function(tool) {
        for (var iTool = 0; iTool < this.tools.length; iTool++) {
            if (this.tools[iTool] == tool) {
                continue;
            }
            this.tools[iTool].turnoff();
        }
    }
    this.clearAllOtherTools = function(tool) {
        for (var iTool = 0; iTool < this.tools.length; iTool++) {
            if (this.tools[iTool] == tool) {
                continue;
            }
            this.tools[iTool].clear();
        }
    }
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
    }
    this.resetAllTools = function() {
        this.resetAllOtherTools();
    }
}
function REagleMap(width, height, target, imgdb, mapdb, topleftX, topleftY) {
    this.toString = function() {
        return 'REagleMap';
    }
    this.target = target;
    this.width = width;
    this.height = height;
    this.imgdb = imgdb;
    this.mapdb = mapdb;
    this.eagleshow = true;
    this.isVisibility = true;
    this.eaglezoomoffset = 4;
    if (topleftX) {
        this.topleftX = topleftX;
    } else {
        this.topleftX = 3;
    }
    if (topleftY) {
        this.topleftY = topleftY;
    } else {
        this.topleftY = 50;
    }
    if (this.target.isValidZoom(this.target.zoom - this.eaglezoomoffset)) {
        this.zoom = this.target.zoom - this.eaglezoomoffset;
    } else {
        this.zoom = 0;
    }
    this.maplet = new RMap(3, 3, this.width - 3, this.height - 3, this.target.lat, this.target.lng, this.zoom, this.mapdb);
    if (this.maplet.logo) {//去掉小地图的logo
        this.maplet.container.removeChild(this.maplet.logo);
    }
    this.maplet.mapmask.oncontextmenu = function() {//屏蔽右键
        if (window.event) {
            window.event.returnValue = false;
        } else {
            document.oncontextmenu = function(e) { return false; };
        }
    }
    this.maplet.isEagleMap = true;
    this.maplet.get().style.border = "1px solid #94AAE3";
    this.maplet.map.ondblclick = null;
    if (this.maplet.errortip) {
        this.maplet.get().removeChild(this.maplet.errortip.get());
    } else {
        this.maplet.errortip = new RToolTip(-1, -1, '', 0);
    }
    this.div = new RDiv(this.target.width - this.width, this.target.height - this.height, this.width, this.height).get();
    this.style = this.div.style;
    this.div.style.zIndex = 10000;
    this.div.style.overflow = 'hidden';
    this.div.style.clip = "rect(0 " + this.width + " " + this.height + " 0)";
    this.div.style.backgroundColor = "#E9F0FA";
    this.div.style.border = "1px solid #849AdD";
    this.mask = new RDiv(this.width / 2 - 50, this.height / 2 - 25, 100, 50).get();
    this.mask.style.cursor = 'pointer';
    this.mask.style.zIndex = 10000;
    if (!this.mask.addEventListener) {
        this.mask.style.filter = "alpha(opacity=30)";
    } else {
        this.mask.style.opacity = 0.3;
    }
    this.mask.oncontextmenu = function() {//屏蔽右键
        if (window.event) {
            window.event.returnValue = false;
        } else {
            document.oncontextmenu = function(e) { return false; };
        }
    }
    this.mask.style.backgroundColor = "#0000FF";
    this.mask.root = this;
    this.mask.isInEagle = function(evt) {
        var left = (evt || window.event).clientX - this.xoffset;
        var top = (evt || window.event).clientY - this.yoffset;
        if (left > this.root.width - parseInt(this.style.width, 10) / 2) {
            return false;
        }
        if (left < 0 - parseInt(this.style.width, 10) / 2) {
            return false;
        }
        if (top > this.root.height - parseInt(this.style.height, 10) / 2) {
            return false;
        }
        if (top < 0 - parseInt(this.style.height, 10) / 2) {
            return false;
        }
        return true;
    }
    this.mask.onmousedown = function(evt) {
        this.drag = true;
        this.dragged = false;
        this.xoffset = (evt || window.event).clientX - parseInt(this.style.left, 10);
        this.yoffset = (evt || window.event).clientY - parseInt(this.style.top, 10);
        if (!evt) {
            this.setCapture();
        }
    }
    this.mask.ondrag = function(evt) {
        if (this.drag && this.isInEagle(evt)) {
            this.style.left = (evt || window.event).clientX - this.xoffset;
            this.style.top = (evt || window.event).clientY - this.yoffset;
        }
    }
    this.mask.ondragend = function(evt) {
        var left = Math.ceil(parseInt(this.style.left, 10) + parseInt(this.style.width, 10) / 2);
        var top = Math.ceil(parseInt(this.style.top, 10) + parseInt(this.style.height, 10) / 2);
        var tmp = this.root.maplet.tilelayers[this.root.maplet.zoom].getLatLng(left, top);
        this.root.target.smoothMove(tmp.lat, tmp.lng);
    }
    this.mask.onmousemove = function(evt) {
        if (this.drag) {
            this.dragged = true;
            this.ondrag(evt);
        }
    }
    this.mouseup = function(evt) {
        if (!evt) {
            this.releaseCapture();
        }
        this.drag = false;
        if (this.dragged) {
            this.ondragend(evt);
            this.dragged = false;
        }
    }
    //	if(this.mask.addEventListener){
    //	    g_addListener("mouseup",this.mouseup,this.mask);
    //	    document.addEventListener("mouseup",g_notify,false);
    //	}else{
    //	    this.mask.onmouseup=this.mouseup;
    //	}
    this.mask.onmouseup = function(evt) {
        if (!evt) {
            this.releaseCapture();
        }
        this.drag = false;
        if (this.dragged) {
            this.ondragend(evt);
            this.dragged = false;
        }
    }
    this.hide = function() {
        this.maplet.hide();
        this.mask.style.visibility = 'hidden';
        this.div.style.visibility = "hidden";
        this.isVisibility = false;
        this.target.logo.style.left = this.target.width - 125;
        this.target.logo.style.top = this.target.height - 18;
    }
    this.show = function() {
        this.maplet.show();
        this.mask.style.visibility = 'visible';
        this.div.style.visibility = 'visible';
        this.isVisibility = true;
        if (this.eagleshow) {
            this.target.logo.style.left = this.target.width - 127 - this.width;
            this.target.logo.style.top = this.target.height - 18;
        } else {
            this.target.logo.style.left = this.target.width - 148;
            this.target.logo.style.top = this.target.height - 18;
        }
    }
    this.div.appendChild(this.maplet.get());
    this.maplet.container.appendChild(this.mask);
    this.maplet.show();
    if (this.target.zoom > this.eaglezoomoffset - 1) {
        this.show();
        this.maplet.setZoomLevel(this.target.zoom - this.eaglezoomoffset);
        this.mask.style.width = this.target.width / this.maplet.scalefactors[this.maplet.zoom] * this.target.scalefactors[this.target.zoom];
        this.mask.style.height = this.target.height / this.maplet.scalefactors[this.maplet.zoom] * this.target.scalefactors[this.target.zoom];
        this.mask.style.left = this.maplet.width / 2 - parseInt(this.mask.style.width, 10) / 2;
        this.mask.style.top = this.maplet.height / 2 - parseInt(this.mask.style.height, 10) / 2;
    }
    else {
        this.hide();
    }
    this.get = function() {
        return this.div;
    }
    this.onboundschanged = function() {
        if (this.target.zoom > this.eaglezoomoffset - 1) {
            if (!this.isVisibility) {
                this.show();
            }
            if (this.eagleshow) {
                this.maplet.setCenter(this.target.lat, this.target.lng);
                //				if(this.target.zoom==4 || this.target.zoom==5 || this.target.zoom==6 || this.target.zoom==7 || this.target.zoom==8 )
                //				{
                //				    this.maplet.setZoomLevel(3);
                //				}
                //				else if(this.target.zoom==9 || this.target.zoom==10 || this.target.zoom==11 || this.target.zoom==12 || this.target.zoom==13 )
                //				{
                //				    this.maplet.setZoomLevel(8);
                //				}
                //				else if(this.target.zoom==14 || this.target.zoom==15 )
                //				{
                //				    this.maplet.setZoomLevel(13);
                //				}
                //				else
                //				{
                //				    this.maplet.setZoomLevel(-1);
                //				}
                this.maplet.setZoomLevel(this.target.zoom - this.eaglezoomoffset);
                this.mask.style.width = this.target.width / this.maplet.scalefactors[this.maplet.newzoom] * this.target.scalefactors[this.target.zoom];
                this.mask.style.height = this.target.height / this.maplet.scalefactors[this.maplet.newzoom] * this.target.scalefactors[this.target.zoom];
                this.mask.style.left = this.maplet.width / 2 - parseInt(this.mask.style.width, 10) / 2;
                this.mask.style.top = this.maplet.height / 2 - parseInt(this.mask.style.height, 10) / 2;
            }
        }
        else {
            if (this.isVisibility) {
                this.hide();
            }
        }
    }
    this.onzoomchanged = function() {
        this.onboundschanged();
    }
    this.root = this;
    this.onresized = function() {
        if (this.eagleshow) {
            this.div.style.left = this.target.width - this.width;
            this.div.style.top = this.target.height - this.height;
            if (this.isVisibility == true) {//logo
                this.root.target.logo.style.left = this.root.target.width - 127 - this.width;
                this.root.target.logo.style.top = this.root.target.height - 18;
            } else {
                this.root.target.logo.style.left = this.root.target.width - 125;
                this.root.target.logo.style.top = this.root.target.height - 18;
            }
        } else {
            this.div.style.left = this.target.width - 19;
            this.div.style.top = this.target.height - 19;
            if (this.isVisibility == true) {//logo
                this.root.target.logo.style.left = this.root.target.width - 148;
                this.root.target.logo.style.top = this.root.target.height - 18;
            } else {
                this.root.target.logo.style.left = this.root.target.width - 125;
                this.root.target.logo.style.top = this.root.target.height - 18;
            }
        }
        this.onboundschanged();
    }
    this.target.addListener(this, 'onboundschanged');
    this.target.addListener(this, 'onzoomchanged');
    this.target.addListener(this, 'onresized');
    this.listener = new Object();
    this.listener.root = this;
    //禁用鹰眼图的滚轮缩放和键盘缩放
    this.maplet.disableWheelZoom();
    this.maplet.disableKeyPan();
    this.listener.onboundschanged = function() {
        this.root.target.smoothMove(this.root.maplet.lat, this.root.maplet.lng);
    }
    /*
    //让大地图响应鹰眼图的缩放
    this.listener.onzoomchanged=function(){
    if(this.root.maplet.zoom>this.root.maplet.zoomlevels-this.root.eaglezoomoffset+1){
    this.root.maplet.setZoomLevel(this.root.maplet.zoomlevels-this.root.eaglezoomoffset+1);
    }else{
    this.root.target.setZoomLevel(this.root.maplet.zoom+this.root.eaglezoomoffset);
    }
    }
    this.maplet.addListener(this.listener,'onzoomchanged');
    */
    this.maplet.addListener(this.listener, 'onboundschanged');
    this.onoff = new RImage(this.width - 19, this.height - 19, this.imgdb + '/overcontract.gif').get();
    this.onoff.title = "隐藏鹰眼图";
    this.onoff.style.zIndex = 10001;
    this.onoff.style.cursor = 'pointer';
    this.div.appendChild(this.onoff);
    this.onoff.root = this;
    this.isdyning = false;
    this.dynCount = 10;
    this.onoff.onclick = function() {
        if (this.root.isdyning) { return; }
        this.root.isdyning = true;
        if (this.root.eagleshow) {
            this.root.eagleshow = false;
            this.root.dynCount = 10;
            this.root.leftdes = this.root.target.width - 19;
            this.root.topdes = this.root.target.height - 19;
            this.root.leftstep = this.root.width / 10;
            this.root.topstep = this.root.height / 10;
            setRTimeout(this.root, this.root.dynHide, 10);
        } else {
            this.root.eagleshow = true;
            this.root.onboundschanged();
            this.root.dynCount = 10;
            this.root.leftdes = this.root.target.width - this.root.width;
            this.root.topdes = this.root.target.height - this.root.height;
            this.root.leftstep = this.root.width / 10;
            this.root.topstep = this.root.height / 10;
            setRTimeout(this.root, this.root.dynShow, 10);
        }
    }
    this.dynHide = function() {
        if (this.dynCount > 0) {
            this.dynCount--;
            this.div.style.left = this.leftdes - this.dynCount * this.leftstep;
            this.div.style.top = this.topdes - this.dynCount * this.topstep;
            this.target.logo.style.left = this.leftdes - 127 - this.dynCount * this.leftstep; //logo
            this.target.logo.style.top = this.target.height - 18;
            setRTimeout(this, this.dynHide, 10);
        } else {
            this.div.style.left = this.leftdes;
            this.div.style.top = this.topdes;
            this.onoff.src = this.imgdb + '/overexpand.gif';
            this.onoff.title = '打开鹰眼图';
            this.onoff.style.left = 0;
            this.onoff.style.top = 0;
            this.isdyning = false;
        }
    }
    this.dynShow = function() {
        if (this.dynCount > 0) {
            this.dynCount--;
            this.div.style.left = this.leftdes + this.dynCount * this.leftstep;
            this.div.style.top = this.topdes + this.dynCount * this.topstep;
            this.target.logo.style.left = this.leftdes - 127 + this.dynCount * this.leftstep; //logo
            this.target.logo.style.top = this.target.height - 18;
            setRTimeout(this, this.dynShow, 10);
        } else {
            this.div.style.left = this.leftdes;
            this.div.style.top = this.topdes;
            this.onoff.src = this.imgdb + '/overcontract.gif';
            this.onoff.title = '关闭鹰眼图';
            this.onoff.style.left = this.width - 19;
            this.onoff.style.top = this.height - 19;
            this.isdyning = false;
        }
    }
    this.showEagleMap = function() {
        if (!this.eagleshow) {
            this.onoff.onclick();
        }
    }
    this.hideEagleMap = function() {
        if (this.eagleshow) {
            this.onoff.onclick();
        }
    }
}
function RLabelPoint(latlng, zIndex, icon, iconlabel, xoffset, yoffset, label, detail) {
    this.type = 'LabelPoint';
    if (!latlng) { return; }
    this.latlng = latlng;
    this.lat = this.latlng.lat;
    this.lng = this.latlng.lng;
    if (!icon) { return; }
    this.icon = icon;
    if (!iconlabel) { return; }
    this.iconlabel = iconlabel;
    if (zIndex) {
        this.zIndex = zIndex;
    } else {
        this.zIndex = 0;
    }
    if (xoffset) {
        this.xoffset = xoffset;
    } else {
        this.xoffset = 0;
    }
    if (yoffset) {
        this.yoffset = yoffset;
    } else {
        this.yoffset = 0;
    }
    this.label = label;
    this.detail = detail;
    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    this.style.zIndex = this.zIndex;
    this.style.fontSize = '12px';
    this.labelImg = new RImage(xoffset, yoffset, this.iconlabel).get();
    this.img = new RImage(0, 0, this.icon).get();
    this.img.style.zIndex = zIndex;
    this.img.onload = function() {
        this.style.left = -this.width / 2;
        this.style.top = -this.height / 2;
    }
    this.img.style.left = -this.img.width / 2;
    this.img.style.top = -this.img.height / 2;
    this.div.appendChild(this.img);
    this.div.appendChild(this.labelImg);
    if (this.detail) {
        this.div.detail = new RFloatDialog(20, 10, this.label.length * 20, this.label, this.detail);
        this.div.detail.get().onmouseover = function() {
            this.depth = this.parentNode.style.zIndex;
            this.parentNode.style.zIndex = 10000;
        }
        this.div.detail.get().onmouseout = function() {
            this.parentNode.style.zIndex = this.depth;
        }
        this.div.detail.style.zIndex = 10000;
        this.div.detail.hide();
        this.div.appendChild(this.div.detail.get());
    }
    this.img.onmouseover = function() {
        this.pin = false;
        if (this.parentNode.style.zIndex != 10000) {
            this.depth = this.parentNode.style.zIndex;
        }
        this.parentNode.style.zIndex = 10000;
        if (!this.parentNode.detail.get().pin) {
            this.parentNode.detail.get().style.left = 20;
            this.parentNode.detail.get().style.top = 10;
        }
        this.parentNode.detail.show();
    }
    this.img.onclick = function() {
        this.pin = true;
        this.parentNode.detail.get().pin = true;
    }
    this.img.onmouseout = function() {
        if (!this.pin && !this.parentNode.detail.get().pin) {
            this.parentNode.style.zIndex = this.depth;
            this.parentNode.detail.hide();
        }
    }
    this.toString = function() {
        return 'RLabelPoint';
    }
    this.get = function() {
        return this.div;
    }
    this.showDetail = function() {
        if (this.detail) {
            this.pin = true;
            this.div.detail.get().pin = true;
            this.div.detail.show();
        }
    }
    this.hideDetail = function() {
        if (this.detail) {
            this.pin = false;
            this.div.detail.get().pin = false;
            this.div.detail.hide();
        }
    }
    this.destroy = function() {
        if (this.labelImg) {
            this.labelImg = null;
        }
        if (this.img) {
            this.img = null;
        }
        if (this.div.detail) {
            this.div.detail = null;
        }
        if (this.div.parentNode) {
            this.div.parentNode.removeChild(this.div);
        }
        this.div = null;
        this.toString = function() { return null; };
    }
}
function RBounds(leftbottom, righttop) {
    this.leftbottom = leftbottom;
    this.righttop = righttop;
    this.startLat = leftbottom.lat;
    this.startLng = leftbottom.lng;
    this.endLat = righttop.lat;
    this.endLng = righttop.lng;
    this.toString = function() {
        return 'RBounds';
    }
}
function RRectRegion(bounds, fillcolor, strokecolor) {
    this.type = "Region";
    this.bounds = bounds;
    this.leftbottom = bounds.leftbottom;
    this.righttop = bounds.righttop;
    this.div = new RDiv(0, 0, null, null).get();
    if (this.div.addEventListener) {
        this.svg = document.createElementNS(SVG_URL, "svg");
        this.svg.setAttribute("version", "1.1");
        this.svg.setAttribute("overflow", "visible");
        this.rect = document.createElementNS(SVG_URL, "rect");
        if (fillcolor) {
            this.rect.setAttribute("fill", fillcolor);
        } else {
            this.rect.setAttribute("fill", "none")
        }
        this.rect.setAttribute("fill-opacity", 0.3);
        if (strokecolor) {
            this.rect.setAttribute("stroke", strokecolor);
        } else {
            this.rect.setAttribute("stroke", "#000000");
        }
        this.rect.setAttribute("stroke-opacity", 0.5);
        this.rect.setAttribute("stroke-width", 1);
        this.div.appendChild(this.svg);
        this.svg.appendChild(this.rect);
    } else {
        this.rect = document.createElement("v:rect");
        this.rect.unselectable = 'on';
        this.style = this.rect.style;
        if (fillcolor) {
            this.rect.fillcolor = fillcolor;
        } else {
            this.rect.filled = "false";
        }
        this.style.filter = 'alpha(opacity=30)';
        this.div.appendChild(this.rect);
    }
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return 'RRectRegion';
    }
    this.destroy = function() {
        if (this.div) {
            if (this.div.parentNode) {
                this.div.parentNode.removeChild(this.div);
            }
            this.div = null;
            if (this.svg) {
                this.svg = null;
            }
            this.rect = null;
        }
        this.toString = function() { return null; };
    }
}
function RCircleRegion(center, radius, fillcolor, strokeColor) {
    this.type = "Region";
    this.center = center;
    this.radius = radius;
    this.div = new RDiv(0, 0, null, null).get();
    if (this.div.addEventListener) {
        this.svg = document.createElementNS(SVG_URL, "svg");
        this.svg.setAttribute("version", "1.1");
        this.svg.setAttribute("overflow", "visible");
        this.oval = document.createElementNS(SVG_URL, "circle");
        if (fillcolor) {
            this.oval.setAttribute("fill", fillcolor);
        }
        this.oval.setAttribute("fill-opacity", 0.3);
        if (strokeColor) {
            this.oval.setAttribute("stroke", strokeColor);
        } else {
            this.oval.setAttribute("stroke", "#000000");
        }
        this.oval.setAttribute("stroke-opacity", 0.5);
        this.oval.setAttribute("stroke-width", 2);
        this.div.appendChild(this.svg);
        this.svg.appendChild(this.oval);
    } else {
        this.oval = document.createElement("v:oval");
        this.style = this.oval.style;
        this.oval.unselectable = 'on';
        this.oval.fillcolor = fillcolor;
        this.oval.style.filter = 'alpha(opacity=30)';
        this.div.appendChild(this.oval);
    }
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return 'RCircleRegion';
    }
    this.destroy = function() {
        if (this.div.parentNode) {
            this.div.parentNode.removeChild(this.div);
        }
        this.oval = null;
        this.div = null;
        this.toString = function() { return null; };
    }
}
function RToolTip(left, top, text, delay) {
    this.left = left;
    this.top = top;
    this.text = text;
    if (delay > 0) {
        this.delay = delay;
    } else {
        this.delay = 10;
    }
    this.counter = 0;
    this.label = new RLabel(left, top, text);
    this.label.hide();
    this.style = this.label.style;
    this.label.get().align = 'center';
    this.style.border = '1px solid #fac194';
    this.style.backgroundColor = '#fff9f4';
    this.toString = function() {
        return 'RToolTip';
    }
    this.get = function() {
        return this.label.get();
    }
    this.show = function() {
        this.label.show();
        this.delayHide();
    }
    this.delayHide = function() {
        if (this.counter < this.delay) {
            setRTimeout(this, this.delayHide, 1000)
            this.counter++;
        } else {
            this.hide();
            this.counter = 0;
        }
    }
    this.hide = function() {
        this.label.hide();
    }
    this.setText = function(text) {
        this.text = text;
        this.label.setText(text);
    }
    this.getText = function() {
        return this.text;
    }
    this.isVisible = function() {
        if (this.label.style.visibility == 'hidden') {
            return false;
        } else {
            return true;
        }
    }
    this.setLeftTop = function(left, top) {
        this.style.left = left;
        this.style.top = top;
    }
}
function RLabel(left, top, text) {
    this.label = document.createElement('Label');
    this.label.style.zIndex = 999;
    this.style = this.label.style;
    this.style.position = 'absolute';
    this.style.left = left;
    this.style.top = top;
    this.style.fontSize = 12;
    this.label.innerHTML = text;
    this.toString = function() {
        return 'RLabel';
    }
    this.get = function() {
        return this.label;
    }
    this.getText = function() {
        if (window.event) {
            return this.label.innerText;
        } else {
            return this.label.textContent;
        }
    }
    this.setText = function(text) {
        this.label.innerHTML = text;
    }
    this.hide = function() {
        this.label.style.visibility = 'hidden';
    }
    this.show = function() {
        this.label.style.visibility = 'visible';
    }
    this.label.root = this;
    this.label.onclick = function() {
        this.root.notify('onclicked');
    }
    this.onclicked = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RSquareMarker(bounds, fillcolor, strokecolor, opacity) {
    this.type = "Region";
    this.bounds = bounds;
    this.leftbottom = bounds.leftbottom;
    this.righttop = bounds.righttop;
    this.div = new RDiv(0, 0, null, null).get();
    if (this.div.addEventListener) {
        this.svg = document.createElementNS(SVG_URL, "svg");
        this.svg.setAttribute("version", "1.1");
        this.svg.setAttribute("overflow", "visible");
        this.rect = document.createElementNS(SVG_URL, "rect");
        if (fillcolor) {
            this.rect.setAttribute("fill", fillcolor);
        } else {
            this.rect.setAttribute("fill", "none")
        }
        this.rect.setAttribute("fill-opacity", 0.3);
        if (strokecolor) {
            this.rect.setAttribute("stroke", strokecolor);
        } else {
            this.rect.setAttribute("stroke", "#000000");
        }
        this.rect.setAttribute("stroke-opacity", 0.5);
        this.rect.setAttribute("stroke-width", 1);
        this.div.appendChild(this.svg);
        this.svg.appendChild(this.rect);
    } else {
        this.rect = document.createElement("v:rect");
        this.rect.unselectable = 'on';
        this.style = this.rect.style;
        if (strokecolor) {
            this.rect.strokecolor = strokecolor;
        } else {
            this.rect.strokecolor = "#000000";
        }
        if (fillcolor) {
            this.rect.fillcolor = fillcolor;
        } else {
            this.rect.filled = "false";
        }
        if (opacity) {
            this.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
        } else {
            this.style.filter = 'alpha(opacity=30)';
        }
        this.div.appendChild(this.rect);
    }
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return 'RSquareMarker';
    }
    this.destroy = function() {
        if (this.div) {
            if (this.div.parentNode) {
                this.div.parentNode.removeChild(this.div);
            }
            this.div = null;
            if (this.svg) {
                this.svg = null;
            }
            this.rect = null;
        }
        this.toString = function() { return null; };
    }
}
function RGpsidArea(maplet, minLatlng, maxLatlng, zIndex, fillcolor, strokecolor, opacity, boxType, title, content, maxContent) {
    this.maplet = maplet;
    //    this.latlngDistance = 0.000218;
    this.leftbottom = minLatlng;
    this.righttop = maxLatlng;
    this.lat = (this.leftbottom.lat * 1000000 + this.righttop.lat * 1000000) / 2000000;
    this.lng = (this.leftbottom.lng * 1000000 + this.righttop.lng * 1000000) / 2000000;
    this.latlng = new Object();
    this.latlng.lat = this.lat;
    this.latlng.lng = this.lng;
    this.zIndex = zIndex;
    this.title = title;
    this.content = content;
    this.maxContent = maxContent;
    this.boxType = boxType;
    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    this.style.zIndex = this.zIndex;
    if (title) {
        this.type = "Region";
        this.bounds = new Object();
        this.bounds.leftbottom = this.leftbottom;
        this.bounds.righttop = this.righttop;
        this.areaDiv = new RDiv(0, 0, null, null).get();
        this.div.appendChild(this.areaDiv);
        this.areaDiv.style.cursor = "pointer";
        if (this.areaDiv.addEventListener) {
            this.svg = document.createElementNS(SVG_URL, "svg");
            this.svg.setAttribute("version", "1.1");
            this.svg.setAttribute("overflow", "visible");
            this.rect = document.createElementNS(SVG_URL, "rect");
            if (fillcolor) {
                this.rect.setAttribute("fill", fillcolor);
            } else {
                this.rect.setAttribute("fill", "none")
            }
            this.rect.setAttribute("fill-opacity", 0.3);
            if (strokecolor) {
                this.rect.setAttribute("stroke", strokecolor);
            } else {
                this.rect.setAttribute("stroke", "#000000");
            }
            this.rect.setAttribute("stroke-opacity", 0.5);
            this.rect.setAttribute("stroke-width", 2);
            this.areaDiv.appendChild(this.svg);
            this.svg.appendChild(this.rect);
        } else {
            this.rect = document.createElement("v:rect");
            this.rect.unselectable = 'on';
            this.style = this.rect.style;
            if (strokecolor) {
                this.rect.strokecolor = strokecolor;
            } else {
                this.rect.strokecolor = "#000000";
            }
            if (fillcolor) {
                this.rect.fillcolor = fillcolor;
            } else {
                this.rect.filled = "false";
            }
            this.rect.strokeweight = 2; //边框宽
            if (opacity) {
                this.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
            } else {
                this.style.filter = 'alpha(opacity=30)';
            }
            this.areaDiv.appendChild(this.rect);
        }
        this.gpsidAreaBox = new RGpsidAreaBox(JS_SERVER + '/rapi/rwidget/rgpsidareabox/img');
        this.div.appendChild(this.gpsidAreaBox.get());
        this.areaDiv.root = this;
        this.areaDiv.onclick = function() {
            if (this.root.gpsidAreaBox.isMaxBox) {
                this.root.gpsidAreaBox.isMaxBox = false;
                if (this.root.gpsidAreaBox.maxibtn) {
                    this.root.gpsidAreaBox.maxibtn.src = this.root.gpsidAreaBox.imgsrc + '/maximize.gif';
                }
            }
            if (this.root.gpsidAreaBox) {
                this.root.gpsidAreaBox.setContent(this.root.boxType, this.root.title, this.root.content);
                this.root.div.style.zIndex = 59999;
                if (this.root.maxContent) {
                    this.root.gpsidAreaBox.setMaximizeContent(this.root.maxWidth, this.root.maxHeight, this.root.maxContent);
                }
                var tmp1 = this.root.maplet.getPixel(this.root.leftbottom.lat, this.root.leftbottom.lng);
                var tmp2 = this.root.maplet.getPixel(this.root.righttop.lat, this.root.righttop.lng);
                var width = Math.abs(tmp2.left - tmp1.left);
                var height = Math.abs(tmp2.top - tmp1.top);
                this.root.gpsidAreaBox.setLocation((width + 8) / 2, height / 2);
                this.root.gpsidAreaBox.show();
            }
            this.root.notify('onclicked');
        }
    } else {
        this.areaDiv.onclick = function() {
            this.root.notify('onclicked');
        }
    }
    this.setMaximizeSize = function(width, height) {
        this.maxWidth = width;
        this.maxHeight = height;
    }
    this.hideBalloonBoxWithoutEvents = function() {
        if (this.gpsidAreaBox) {
            this.gpsidAreaBox.hideWithoutEvents();
        }
    }
    this.toString = function() {
        return 'RGpsidArea';
    }
    this.get = function() {
        return this.div;
    }
    this.onclicked = new Array();
    this.onDragEnd = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onboxclosed':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onmaxboxclosed':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onminboxclosed':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxopened':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxmaximized':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxrestored':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxresized':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onDragEnd':
                if (listener.onDragEnd) {
                    this.onDragEnd[this.onDragEnd.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onDragEnd':
                for (var i = 0; i < this.onDragEnd.length; i++) {
                    if (this.onDragEnd[i].onDragEnd) {
                        this.onDragEnd[i].onDragEnd();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RGpsidAreaBox(imgsrc) {
    this.isOpen = false;
    this.isMaxBox = false;
    this.imgsrc = imgsrc;
    this.content = "";
    this.maxContent = "";
    this.towAdWidth = 370;
    this.towAdHeight = 340;
    this.rightAdWidth = 370;
    this.rightAdHeight = 230;
    this.noAdWidth = 320;
    this.noAdHeight = 260;
    this.width = this.rightAdWidth;
    this.height = this.rightAdHeight;
    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    this.innerdiv = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdiv);
    this.innerdivFoot = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdivFoot);
    if (!this.closebtn) {
        this.closebtn = new RImage(0, 13, this.imgsrc + '/close.gif').get();
        this.closebtn.style.display = "none";
    }
    this.closebtn.style.cursor = 'pointer';
    this.closebtn.root = this;
    this.div.appendChild(this.closebtn);
    this.closebtn.onclick = function() {
        this.root.hide();
        this.root.innerdiv.innerHTML = '';
        this.root.innerdivFoot.innerHTML = "";
    }
    this.setContent = function(num, title, content) {
        this.title = title;
        this.content = content;
        switch (num) {
            case 1:
                this.width = this.towAdWidth;
                this.height = this.towAdHeight;
                break;
            case 2:
                this.width = this.rightAdWidth;
                this.height = this.rightAdHeight;
                break;
            case 3:
                this.width = this.noAdWidth;
                this.height = this.noAdHeight;
                break;
            default:
                this.width = this.rightAdWidth;
                this.height = this.rightAdHeight;
                break;
        }
        this.setInnerHTML(this.width, this.height, this.title, this.content);
    }
    this.setMaximizeContent = function(width, height, maxContent) {
        if (!width || !height || !maxContent) {
            return;
        }
        this.maxWidth = width;
        this.maxHeight = height;
        this.maxContent = maxContent;
        if (this.maxContent) {
            if (!this.maxibtn) {
                this.maxibtn = new RImage(this.width - 50, 13, this.imgsrc + '/maximize.gif').get();
                this.maxibtn.style.cursor = 'pointer';
            }
            this.maxibtn.root = this;
            this.maxibtn.onclick = function() {
                this.root.maximize();
            }
            this.div.appendChild(this.maxibtn);
        }
    }
    this.maximize = function() {
        if (this.maxWidth && this.maxHeight && this.maxContent) {
            this.isMaxBox = true;
            this.setInnerHTML(this.maxWidth, this.maxHeight, this.title, this.maxContent);
            this.maxibtn.src = this.imgsrc + '/restore.gif';
            this.maxibtn.onclick = function() {
                this.root.restore();
            }
            this.setLocation(this.left, this.top);
            this.notify('onboxmaximized');
        }
    }
    this.restore = function() {
        this.isMaxBox = false;
        this.setInnerHTML(this.width, this.height, this.title, this.content);
        this.maxibtn.src = this.imgsrc + '/maximize.gif';
        this.maxibtn.onclick = function() {
            this.root.maximize();
        }
        this.setLocation(this.left, this.top);
        this.notify('onboxrestored');
    }
    this.setInnerHTML = function(width, height, title, content) {
        if (this.closebtn) {
            this.closebtn.style.left = width - 30;
            this.closebtn.style.display = "block";
        }
        if (this.maxibtn) {
            this.maxibtn.style.left = width - 50;
        }
        this.innerdiv.innerHTML = '<table width="' + width + '" height="' + (parseInt(height) - 37) + '" style="" cellpadding="0" cellspacing="0" border="0">' +
'<tr>' +
'<td width="10" height="10" style="background-image:url(' + this.imgsrc + '/balloon_01.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_02.gif);background-repeat:repeat-x">' +
'</td>' +
'<td width="10" style="background-image:url(' + this.imgsrc + '/balloon_04.gif);background-Repeat:no-repeat">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td  height="22" style="background-image:url(' + this.imgsrc + '/balloon_05.gif);background-repeat:repeat-y">' +
'</td>' +
'<td id="" style="background-color:#FDE5B7;font-size:12px;font-family:宋体;font-weight:bold;" align="left">' +
'<div style="margin-left:10px;">' + title + '</div>' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_07.gif);background-repeat:repeat-y">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td height="1" style="background-image:url(' + this.imgsrc + '/balloon_10.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_11.gif);background-repeat:repeat-x">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_12.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_13.gif);background-repeat:repeat-y">' +
'</td>' +
'<td style="font-size:12px;font-family:宋体;background-color:#FFFDF2">' +
'<div id="" style="width:' + (width - 20) + ';height:' + (height - 80) + ';overflow:auto; padding:5px 10px;">' +
content +
'</div>' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_15.gif);background-repeat:repeat-y">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td height="10" style="background-image:url(' + this.imgsrc + '/balloon_18.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_19.gif);background-repeat:repeat-x" align="center">' +
        //						'<img src="'+this.imgsrc+'/balloon_21.gif" width="13" height="47" unselectable="on" border="0">'+
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_23.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'</table>';
        this.innerdivFoot.style.left = (parseInt(width) - 13) / 2;
        this.innerdivFoot.style.top = parseInt(height) - 47;
        this.innerdivFoot.innerHTML = '<table width="13" height="47" cellpadding="0" cellspacing="0" border="0">' +
'<tr><td ><img src="' + this.imgsrc + '/balloon_21.gif" width="13" height="47" unselectable="on" border="0">' +
'</td>' +
'</tr>' +
'</table>';
    }
    this.setLocation = function(left, top) {
        this.left = left;
        this.top = top;
        if (this.isMaxBox) {
            this.style.left = this.left - this.maxWidth / 2;
            this.style.top = this.top - this.maxHeight;
        } else {
            this.style.left = this.left - this.width / 2;
            this.style.top = this.top - this.height;
        }
    }
    this.setLocationMaxbox = function(left, top) {
        this.left = left;
        this.top = top;
        this.style.left = this.left - this.maxWidth / 2;
        this.style.top = this.top - this.maxHeight;
    }
    this.hide = function() {
        this.notify('onboxclosed');
        this.hideWithoutEvents();
    }
    this.hideWithoutEvents = function() {
        this.style.visibility = 'hidden';
        this.isOpen = false;
        this.innerdiv.innerHTML = "";
    }
    this.show = function() {
        this.style.visibility = 'visible';
        this.isOpen = true;
        this.notify('onboxopened');
    }
    this.get = function() {
        return this.div;
    }
    this.onmaxboxclosed = new Array();
    this.onminboxclosed = new Array();
    this.onboxclosed = new Array();
    this.onboxopened = new Array();
    this.onboxmaximized = new Array();
    this.onboxrestored = new Array();
    this.onboxresized = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onboxclosed':
                if (listener.onboxclosed) {
                    this.onboxclosed[this.onboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onmaxboxclosed':
                if (listener.onmaxboxclosed) {
                    this.onmaxboxclosed[this.onmaxboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onminboxclosed':
                if (listener.onminboxclosed) {
                    this.onminboxclosed[this.onminboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxopened':
                if (listener.onboxopened) {
                    this.onboxopened[this.onboxopened.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxmaximized':
                if (listener.onboxmaximized) {
                    this.onboxmaximized[this.onboxmaximized.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxrestored':
                if (listener.onboxrestored) {
                    this.onboxrestored[this.onboxrestored.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxresized':
                if (listener.onboxresized) {
                    this.onboxresized[this.onboxresized.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onboxopened':
                for (var i = 0; i < this.onboxopened.length; i++) {
                    if (this.onboxopened[i].onboxopened) {
                        this.onboxopened[i].onboxopened();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxclosed':
                for (var i = 0; i < this.onboxclosed.length; i++) {
                    if (this.onboxclosed[i].onboxclosed) {
                        this.onboxclosed[i].onboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onmaxboxclosed':
                for (var i = 0; i < this.onmaxboxclosed.length; i++) {
                    if (this.onmaxboxclosed[i].onmaxboxclosed) {
                        this.onmaxboxclosed[i].onmaxboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onminboxclosed':
                for (var i = 0; i < this.onminboxclosed.length; i++) {
                    if (this.onminboxclosed[i].onminboxclosed) {
                        this.onminboxclosed[i].onminboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxmaximized':
                for (var i = 0; i < this.onboxmaximized.length; i++) {
                    if (this.onboxmaximized[i].onboxmaximized) {
                        this.onboxmaximized[i].onboxmaximized();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxrestored':
                for (var i = 0; i < this.onboxrestored.length; i++) {
                    if (this.onboxrestored[i].onboxrestored) {
                        this.onboxrestored[i].onboxrestored();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxresized':
                for (var i = 0; i < this.onboxresized.length; i++) {
                    if (this.onboxresized[i].onboxresized) {
                        this.onboxresized[i].onboxresized();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RDistanceTool(tool) {
    //在同一次测量中，测量的数目，1为1条，不为1为多条
    this.DrawDistanceTimes = 1;
    if (!tool) { return; }
    this.tool = tool;
    this.maplet = null;
    this.resultBox = null;
    this.showresult = "";
    this.isKeepOtherMarker = false;
    this.LabelMarkers = new Array();
    this.clickcount = 0;
    this.fDistance = 0;
    this.pathTool = new RPathTool(this.tool);
    this.pathTool.Parent = this;
    //	this.isLock=this.pathTool.isLock;
    this.isLock = true;
    window.winDistanceTool = this;
    this.toString = function() {
        return 'RDistanceTool';
    }
    this.turnon = function() {
        this.isLock = false;
        this.pathTool.turnon();
        this.addEvt();
        if (this.DrawDistanceTimes == 1) {
            this.clear();
        }
    }
    this.pathlistener = new Object();
    this.pathlistener.root = this;
    this.pathlistener.onclicked = function() {
        if (this.root.clickcount > 0) {
            if (!this.root.resultBox) {
                this.root.resultBox = new RFloatDialog(this.root.maplet.width - 180, 50, 150, '测距结果', '');
                this.root.maplet.get().appendChild(this.root.resultBox.get());
                this.root.resultBox.get().style.zIndex = 1002;
            }
            var distance = getPathDistance(this.root.pathTool.latlngs);
            if (parseInt(distance) > 0) {
                if (distance == 'NaN') {
                    debugger;
                }
                this.root.resultBox.setContent("测距结果为" + Math.round(distance) + "米。<br>合计" + Math.round(distance) / 1000 + "公里。<br>");
                this.root.resultBox.show();
                var sharedistance = parseInt(distance) - this.root.fDistance;
                if (sharedistance > 0) {
                    var tempDistance = null;
                    if (sharedistance > 0) {
                        if (sharedistance < 1000) {
                            tempDistance = Math.round(sharedistance) + "米";
                            //temp="<table><tr><td></td></tr></table>"
                        } else {
                            tempDistance = Math.round(sharedistance) / 1000 + "公里";
                        }
                    }
                    if (tempDistance) {
                        this.root.LabelMarkers[this.root.LabelMarkers.length] = this.root.maplet.addMapLabelMarker(this.root.pathTool.latlngs[this.root.clickcount], 100, tempDistance, 70);
                    }
                }
                this.root.maplet.refreshMarkers();
                this.root.fDistance = parseInt(distance);
            }
        }
        this.root.clickcount++;
        this.root.maplistener = new Object();
        this.root.maplistener.root = this.root;
        this.root.maplistener.onresized = function() {
            if (this.root.resultBox) {
                this.root.resultBox.div.style.left = this.root.maplet.width - 180;
                this.root.resultBox.div.style.top = 50;
            }
        }
        this.root.maplet.addListener(this.root.maplistener, 'onresized');
    }
    this.pathlistener.onbegin = function() {
        this.root.fDistance = 0;
        this.root.showresult = "";
        this.root.clickcount = 0;
        if (this.root.resultBox) {
            this.root.resultBox.hide();
        }
        //		this.root.pathTool.ondbclk = false;//还原双击是否发生的判断为false
    }
    this.pathlistener.onsuccess = function() {
        this.root.showResult();
        $("MapmoveTool").className = "unite_MapmoveToolOn";
        this.root.tool.className = "unite_DistanceToolOff";

    }
    this.pathTool.addListener(this.pathlistener, 'onbegin');
    this.pathTool.addListener(this.pathlistener, 'onclicked');
    this.pathTool.addListener(this.pathlistener, 'onsuccess');
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
        this.pathTool.setMaplet(this.maplet);
    }
    this.showResult = function() {
        if (this.pathTool.markers.length > 0) {
            var distance = getPathDistance(this.pathTool.markers[this.pathTool.markers.length - 1].latlngs);
            if (distance == 'NaN') {
                debugger;
            }
            this.showresult = '测距结果为' + Math.round(distance) + '米。<br>合计' + Math.round(distance) / 1000 + '公里。';
            if (this.resultBox != null) {
                this.resultBox.setContent(this.showresult);
                this.clickcount = 0;
                this.fDistance = 0;
            }
        }
    }
    this.turnoff = function() {
        //	    if(this.pathTool.ondbclk == true)//双击发生
        //	    {
        //	        this.pathTool.turnoff();
        //	    }
        //	    else
        //	    {
        this.isLock = true;
        for (var i = 1; i < this.pathTool.clickcount; i++) {
            this.LabelMarkers[this.LabelMarkers.length - 1].destroy();
            this.LabelMarkers.pop();
        }
        this.fDistance = 0;
        this.pathTool.turnoff();
        this.showResult();
        this.showresult = "";
        this.clickcount = 0;
        this.clear();
        //		}
    }
    this.clear = function() {
        for (var i = 0; i < this.LabelMarkers.length; i++) {
            this.LabelMarkers[i].destroy();
        }
        this.LabelMarkers = new Array();
        if (this.resultBox) {
            this.resultBox.hide();
            this.resultBox = null;
        }
        this.pathTool.clear();
    }
    this.addListener = function(listener, estring) {
        this.pathTool.addListener(listener, estring);
    }
    this.keydown = function(evt) {
        if ((evt || window.event).keyCode == 27) {
            this.turnoff();
            this.delEvt();
            this.clear();
        }
    }
    //创建一个Esc建的监听事件
    this.addEvt = function() {
        if (window.event) { //IE
            //	        document.attachEvent("onkeydown",this.keydown);
            g_addListener("keydown", this.keydown, this);
            document.attachEvent("onkeydown", g_notify);
        } else {  //Firefox
            //            document.addEventListener("keydown",this.keydown,false);
            g_addListener("keydown", this.keydown, this);
            document.addEventListener("keydown", g_notify, false);
        }
    }
    //销毁ESC键的监听事件
    this.delEvt = function() {
        if (document.attachEvent) {
            document.detachEvent("onkeydown", g_notify);
        } else {
            document.removeEventListener("keydown", g_notify, false);
        }
    }
}
function RPathTool(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.markers = new Array();
    this.maplet = null;
    this.latlngs = null;
    //    this.isUnique=false;
    this.lastMarker = null;
    this.isLock = true; //是否开启测距
    this.isKeepOtherMarker = false;
    //    this.isTurnOn=false;
    //    this.ondbclk = false;//是否有双击false为否
    if (tool.src) {
        this.imgpath = this.tool.src;
    }
    this.toString = function() {
        return 'RPathTool';
    }
    this.turnon = function() {
        if (this.begined) { return; }
        //	    this.isLock=false;
        //		this.isTurnOn = true;
        this.notify('onturnon');
        this.isLock = false;
        this.clickcount = 0;
        this.begined = true;
        this.drawing = false;
        this.maplet.setCursor('crosshair');
        this.maplet.disableDoubleClick();
        if (!this.tiplbl) {
            this.tiplbl = new RLabel(-100, -100, "<table width='148' border='0' cellpadding='0' cellspacing='0' style='font-size:12px; border-right: #666699 1px solid; border-top: #666699 1px solid; border-left: #666699 1px solid; border-bottom: #666699 1px solid'><tr><td align='left' width='148' height='14' valign='top' style='background-color: #FFFEF2'>单击加点，双击结束，<br>拖动平移，滚轮缩放。</td></tr></table>");
            this.tiplbl.style.filter = 'glow(color=#FFFFFF,strength=2)';
            this.maplet.get().appendChild(this.tiplbl.get());
            this.tiplbl.style.visibility = 'visible';
        } else {
            this.tiplbl.setText("<table width='148' border='0' cellpadding='0' cellspacing='0' style='font-size:12px; border-right: #666699 1px solid; border-top: #666699 1px solid; border-left: #666699 1px solid; border-bottom: #666699 1px solid'><tr><td align='left' width='148' height='14' valign='top' style='background-color: #FFFEF2'>单击加点，双击结束，<br>拖动平移，滚轮缩放。</td></tr></table>");
            this.tiplbl.style.visibility = 'visible';
        }
        this.maplistener = new Object();
        this.maplistener.root = this;
        this.maplistener.onclicked = function() {
            if (this.root.clickcount == 0) {
                this.root.notify('onbegin');
                this.root.markers[this.root.markers.length] = null;
            }
            if (!this.root.drawing) {
                this.root.maplet.setCursor('crosshair');
                this.root.drawing = true;
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = left + 20;
                this.root.tiplbl.style.top = top + 20;
                var latlng = this.root.maplet.getLatLng(left, top);
                var latlngs = new Array();
                latlngs.push(latlng);
                latlngs.push(latlng);
                this.root.markers[this.root.markers.length - 1] = this.root.maplet.addStaticPathMarker([latlng], '#FF0000', 2, 0.5, "distance");
                this.root.lastMarker = this.root.maplet.addStaticPathMarker(latlngs, '#FF0000', 2, 0.5);
                this.root.maplet.refreshStaticMarkers();
            } else {
                this.root.maplet.setCursor('crosshair');
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                var latlng = this.root.maplet.getLatLng(left, top);
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length] = latlng;
                this.root.lastMarker.latlngs[0] = latlng;
                this.root.maplet.refreshStaticMarkers();
            }
            this.root.latlngs = this.root.markers[this.root.markers.length - 1].latlngs;
            this.root.clickcount++;
            this.root.notify('onclicked');
        }
        this.maplistener.onmousemoved = function() {
            if (this.root.drawing) {
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = left + 20;
                this.root.tiplbl.style.top = top + 20;
                var latlng = this.root.maplet.getLatLng(left, top);
                this.root.lastMarker.latlngs[1] = latlng;
                this.root.maplet.refreshStaticMarkers();
                var distance = Math.round(getPathDistance(this.root.lastMarker.latlngs));
                var tempstr1 = "<font color='#FF0000'>" + distance + "</font>米";
                var tempstr2 = "<font color='#FF0000'>" + Math.round(getPathDistance(this.root.markers[this.root.markers.length - 1].latlngs) + distance) + "</font>米"
                if (distance > 1000) {
                    tempstr1 = "<font color='#FF0000'>" + distance / 1000 + "</font>公里";
                }
                if (Math.round(getPathDistance(this.root.markers[this.root.markers.length - 1].latlngs) + distance) > 1000) {
                    tempstr2 = "<font color='#FF0000'>" + (Math.round(getPathDistance(this.root.markers[this.root.markers.length - 1].latlngs) + distance)) / 1000 + "</font>公里"
                }
                this.root.tiplbl.setText("<table width='148' border='0' cellpadding='0' cellspacing='0' style='font-size:12px; border-right: #666699 1px solid; border-top: #666699 1px solid; border-left: #666699 1px solid; border-bottom: #666699 1px solid'><tr><td align='left' width='148' height='14' valign='top' style='background-color: #FFFEF2'>单击加点，双击结束，<br>拖动平移，滚轮缩放。</td></tr><tr><td align='left' width='148' height='14' valign='top' style='background-color: #FFFEF2'>移动段距离：" + tempstr1 + "<br>总距离：" + tempstr2 + "</td></tr></table>");
            } else if (this.root.begined) {
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = left + 20;
                this.root.tiplbl.style.top = top + 20;
            }
        }
        this.maplistener.ondblclicked = function(evt) {
            if (this.root.drawing) {
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = -100;
                this.root.tiplbl.style.top = -100;
                //				this.root.tiplbl.style.visibility='hidden';
                var latlng = this.root.maplet.getLatLng(left, top);
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length] = latlng;
                this.root.markers[this.root.markers.length - 1].isSuccess = true;
                this.root.lastMarker.destroy();
                this.root.maplet.refreshStaticMarkers();
                this.root.latlngs = this.root.markers[this.root.markers.length - 1].latlngs;
                this.root.drawOver();
                this.root.notify('onsuccess');
                this.root.maplet.setCursor('crosshair');
                //				this.root.ondbclk = true;//双击发生
                if (this.root.Parent.DrawDistanceTimes == 1) {
                    this.root.Parent.isLock = true; //设置父亲的isLock为锁定
                    this.root.turnoff();
                }
            }
        }
        this.maplet.addListener(this.maplistener, 'onclicked');
        this.maplet.addListener(this.maplistener, 'onmousemoved');
        this.maplet.addListener(this.maplistener, 'ondblclicked');
    }
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
    }
    this.drawOver = function() {
        this.drawing = false;
        this.begined = false;
        this.clickcount = 0;
    }
    this.turnoff = function() {
        //	    this.isTurnOn=false;
        this.isLock = true;
        if (this.maplistener) {
            this.maplistener.onclicked = function() { };
            this.maplistener.onmousemoved = function() { };
            this.maplistener.ondblclicked = function() { };
        }
        this.drawOver();
        this.maplet.enableDoubleClick();
        this.maplet.setCursor('default');
        if (this.markers.length > 0) {
            if (!this.markers[this.markers.length - 1].isSuccess) {
                this.markers[this.markers.length - 1].destroy();
                this.markers.pop();
            }
        }
        if (this.lastMarker) {
            this.lastMarker.destroy();
            this.lastMarker = null;
        }
        if (this.tiplbl) {
            this.tiplbl.style.left = -100;
            this.tiplbl.style.top = -100;
            this.tiplbl.style.visibility = 'hidden';
        }
        if (this.imgpath) {
            this.tool.src = this.imgpath;
        }
        this.notify('onturnoff');
    }
    this.clear = function() {
        for (var imarker = 0; imarker < this.markers.length; imarker++) {
            if (this.markers[imarker]) {
                this.markers[imarker].destroy();
            }
        }
        this.markers = new Array();
    }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.onclicked = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RMapLabel(latlng, zIndex, text, opacity) {
    this.latlng = latlng;
    this.lat = latlng.lat;
    this.lng = latlng.lng;
    this.text = text;
    this.div = new RLabel(0, 0, text).get();
    this.style = this.div.style;
    this.div.style.zIndex = zIndex;
    this.style.backgroundColor = '#FFFF00';
    this.style.padding = '2px';
    this.style.border = '1px solid #000000';
    this.get = function() {
        return this.div;
    }
    this.toString = function() {
        return "RMapLabel";
    }
    this.setText = function(text) {
        this.text = text;
        if (this.div.innerText) {
            this.div.innerText = text;
        } else {
            this.div.textContent = text;
        }
    }
    this.getText = function() {
        if (this.div.addEventListener) {
            return this.div.textContent;
        } else {
            return this.div.innerText;
        }
    }
    this.show = function() {
        this.div.style.visibility = 'visible';
    }
    this.hide = function() {
        this.div.style.visibility = 'hidden';
    }
    this.destroy = function() {
        if (this.div.parentNode) {
            this.div.parentNode.removeChild(this.div);
        }
        this.div = null;
    }
    this.onclicked = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RAreaTool(tool) {
    //同一次测量中，测量的数目，1为1条，不为1为多条
    this.DrawAreaTimes = 1;
    if (!tool) { return; }
    this.tool = tool;
    this.maplet = null;
    this.resultBox = null;
    this.isLock = true;
    this.isKeepOtherMarker = false;
    this.toString = function() {
        return 'RAreaTool';
    }
    window.winAreaTool = this;
    this.polygonTool = new RPolygonTool(this.tool);
    this.polygonTool.Parent = this;
    this.polygonlistener = new Object();
    this.polygonlistener.root = this;
    this.polygonlistener.onsuccess = function() {
        var area = Math.round(getPolygonArea(this.root.polygonTool.latlngs));
        if (parseInt(area) > 0) {
            if (!this.root.resultBox) {
                this.root.resultBox = new RFloatDialog(this.root.maplet.width - 180, 50, 150, '测面结果', '');
                this.root.maplet.get().appendChild(this.root.resultBox.get());
                this.root.resultBox.get().style.zIndex = 1002;
            }
            var resultstr = '测面结果为' + area + '平方米<br>';
            if (Math.round(area / 1000) / 1000 != 0) {
                resultstr += '合计' + Math.round(area / 1000) / 1000 + '平方公里';
            }
            this.root.resultBox.setContent(resultstr);
            this.root.resultBox.show();
        }
        this.root.maplistener = new Object();
        this.root.maplistener.root = this.root;
        this.root.maplistener.onresized = function() {
            if (this.root.resultBox) {
                this.root.resultBox.div.style.left = this.root.maplet.width - 180;
                this.root.resultBox.div.style.top = 50;
            }
        }
        this.root.maplet.addListener(this.root.maplistener, 'onresized');
    }
    this.polygonlistener.onturnon = function() {
        this.root.addEvt();
    }
    this.polygonlistener.onbegin = function() {
        //	    if(this.DrawAreaTimes == 1)
        //		{
        //		    this.root.clear();
        //		}
    }
    this.polygonTool.addListener(this.polygonlistener, 'onbegin');
    this.polygonTool.addListener(this.polygonlistener, 'onturnon');
    this.polygonTool.addListener(this.polygonlistener, 'onsuccess');
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
        this.polygonTool.setMaplet(this.maplet);
    }
    this.turnon = function() {
        this.isLock = false;
        this.polygonTool.turnon();
        if (this.DrawAreaTimes == 1) {
            this.clear();
        }
    }
    this.turnoff = function() {
        this.isLock = true;
        this.polygonTool.turnoff();
        this.clear();
    }
    this.clear = function() {
        if (this.resultBox) {
            this.resultBox.hide();
            this.resultBox = null;
        }
        this.polygonTool.clear();
    }
    this.addListener = function(listener, estring) {
        this.polygonTool.addListener(listener, estring);
    }
    this.keydown = function(evt) {
        if ((evt || window.event).keyCode == 27) {
            this.turnoff();
            this.delEvt();
            this.clear();
        }
    }
    //创建一个Esc建的监听事件
    this.addEvt = function() {
        if (window.event) { //IE
            g_addListener("keydown", this.keydown, this);
            document.attachEvent("onkeydown", g_notify);
        } else {  //Firefox
            g_addListener("keydown", this.keydown, this);
            document.addEventListener("keydown", g_notify, false);
        }
    }
    //销毁ESC键的监听事件
    this.delEvt = function() {
        if (document.attachEvent) {
            document.detachEvent("onkeydown", g_notify);
        } else {
            document.removeEventListener("keydown", g_notify, false);
        }
    }
}
function RPolygonTool(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.latlngs = null;
    this.maplet = null;
    this.markers = new Array();
    this.clickcount = 0;
    this.isLock = true; //是否开启侧面
    this.isKeepOtherMarker = false;
    //	this.isTurnOn=false;
    if (tool.src) {
        this.imgpath = this.tool.src;
    }
    this.toString = function() {
        return 'RPolygonTool';
    }
    this.turnon = function() {
        this.isLock = false;
        //	    this.isTurnOn=true;
        if (this.begined) { return; }
        this.notify('onturnon');
        this.begined = true;
        this.maplet.setCursor('crosshair');
        this.maplet.disableDoubleClick();
        if (!this.tiplbl) {
            this.tiplbl = new RLabel(-100, -100, "<table width='148' border='0' cellpadding='0' cellspacing='0' style='border-right: #666699 1px solid; border-top: #666699 1px solid; border-left: #666699 1px solid; border-bottom: #666699 1px solid'><tr><td align='left' width='148' height='14' valign='top' style='font-size:12px; background-color: #FFFEF2'>单击加点，双击结束，拖动平移，滚轮缩放。</td></tr></table>");
            this.tiplbl.style.filter = 'glow(color=#FFFFFF,strength=2)';
            this.maplet.get().appendChild(this.tiplbl.get());
            this.tiplbl.style.visibility = 'visible';
        } else {
            this.tiplbl.style.visibility = 'visible';
        }
        this.maplistener = new Object();
        this.maplistener.root = this;
        this.maplistener.onclicked = function() {
            if (this.root.clickcount == 0) {
                this.root.notify('onbegin');
                this.root.markers[this.root.markers.length] = null;
            }
            if (!this.root.drawing) {
                this.root.maplet.setCursor('crosshair');
                this.root.drawing = true;
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = left + 10;
                this.root.tiplbl.style.top = top + 20;
                var latlng = this.root.maplet.getLatLng(left, top);
                var latlngs = new Array();
                latlngs.push(latlng);
                latlngs.push(latlng);
                this.root.markers[this.root.markers.length - 1] = this.root.maplet.addStaticRegionMarker(latlngs, '#0000ff', '#FFFFFF', 1);
                this.root.maplet.refreshStaticMarkers();
            } else {
                this.root.maplet.setCursor('crosshair');
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                var latlng = this.root.maplet.getLatLng(left, top);
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length - 1] = latlng;
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length] = this.root.markers[this.root.markers.length - 1].latlngs[0];
                this.root.maplet.refreshStaticMarkers();
            }
            this.root.clickcount++;
        }
        this.maplistener.onmousemoved = function() {
            if (this.root.drawing) {
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = left + 10;
                this.root.tiplbl.style.top = top + 20;
                var latlng = this.root.maplet.getLatLng(left, top);
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length - 2] = latlng;
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length - 1] = this.root.markers[this.root.markers.length - 1].latlngs[0];
                this.root.maplet.refreshStaticMarkers();
                if (this.root.clickcount > 1) {
                    var noncearea = Math.round(getPolygonArea(this.root.markers[this.root.markers.length - 1].latlngs));
                    this.root.tiplbl.setText("<table width='148' border='0' cellpadding='0' cellspacing='0' style='border-right: #666699 1px solid; border-top: #666699 1px solid; border-left: #666699 1px solid; border-bottom: #666699 1px solid'><tr><td align='left' width='148' height='14' valign='top' style='font-size:12px; background-color: #FFFEF2'>单击加点，双击结束，拖动平移，滚轮缩放。</td></tr><tr><td align='left' width='148' height='14' valign='top' style='background-color: #FFFEF2'>面积：<font color='#FF0000'>" + noncearea + "</font>平方米<br>合计：<font color='#FF0000'>" + (Math.round(noncearea / 1000) / 1000) + "</font>平方公里</td></tr></table>");
                }
                else {
                    this.root.tiplbl.setText("<table width='148' border='0' cellpadding='0' cellspacing='0' style='border-right: #666699 1px solid; border-top: #666699 1px solid; border-left: #666699 1px solid; border-bottom: #666699 1px solid'><tr><td align='left' width='148' height='14' valign='top' style='font-size:12px; background-color: #FFFEF2'>单击加点，双击结束，拖动平移，滚轮缩放。</td></tr></table>");
                }
                //debugger;
            } else if (this.root.begined) {
                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = left + 10;
                this.root.tiplbl.style.top = top + 20;
            }
        }
        this.maplistener.ondblclicked = function() {
            if (this.root.drawing) {
                $("MapmoveTool").className = "unite_MapmoveToolOn";
                this.root.tool.className = "unite_AreaToolOff";

                var bounds = getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode));
                var left = this.root.maplet.mouseX - bounds.left;
                var top = this.root.maplet.mouseY - bounds.top;
                this.root.tiplbl.style.left = -100;
                this.root.tiplbl.style.top = -100;
                this.root.tiplbl.style.visibility = 'hidden';
                var latlng = this.root.maplet.getLatLng(left, top);
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length - 1] = latlng;
                this.root.markers[this.root.markers.length - 1].latlngs[this.root.markers[this.root.markers.length - 1].latlngs.length] = this.root.markers[this.root.markers.length - 1].latlngs[0];
                this.root.markers[this.root.markers.length - 1].isSuccess = true;
                this.root.maplet.refreshStaticMarkers();
                this.root.latlngs = this.root.markers[this.root.markers.length - 1].latlngs;
                this.root.tiplbl.setText("<table width='148' border='0' cellpadding='0' cellspacing='0' style='border-right: #666699 1px solid; border-top: #666699 1px solid; border-left: #666699 1px solid; border-bottom: #666699 1px solid'><tr><td align='left' width='148' height='14' valign='top' style='font-size:12px; background-color: #FFFEF2'>单击加点，双击结束，拖动平移，滚轮缩放。</td></tr></table>");
                this.root.drawOver();
                this.root.notify('onsuccess');
                this.root.maplet.setCursor('crosshair');
                if (this.root.Parent.DrawAreaTimes == 1) {
                    this.root.Parent.isLock = true; //设置父亲的isLock为锁定
                    this.root.turnoff();
                }
            }
        }
        this.maplet.addListener(this.maplistener, 'onclicked');
        this.maplet.addListener(this.maplistener, 'onmousemoved');
        this.maplet.addListener(this.maplistener, 'ondblclicked');
    }
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
    }
    this.drawOver = function() {
        this.drawing = false;
        this.begined = false;
        this.clickcount = 0;
    }
    this.turnoff = function() {
        //	    this.isTurnOn=false;
        this.isLock = true;
        if (this.tiplbl) {
            this.tiplbl.style.left = -100;
            this.tiplbl.style.top = -100;
            this.tiplbl.style.visibility = 'hidden';
        }
        if (this.markers[this.markers.length - 1]) {
            if (!this.markers[this.markers.length - 1].isSuccess) {
                this.markers[this.markers.length - 1].destroy();
                this.markers.pop();
            }
        }
        if (this.maplistener) {
            this.maplistener.onclicked = function() { };
            this.maplistener.onmousemoved = function() { };
            this.maplistener.ondblclicked = function() { };
        }
        this.maplet.enableDoubleClick();
        this.maplet.setCursor('default');
        this.drawOver();
        if (this.imgpath) {
            this.tool.src = this.imgpath;
        }
        this.notify('onturnoff');
    }
    this.clear = function() {
        for (var imarker = 0; imarker < this.markers.length; imarker++) {
            if (this.markers[imarker]) {
                this.markers[imarker].destroy();
            }
        }
        this.markers = new Array();
    }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.onclicked = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RZoominTool(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.maplet = null;
    this.isKeepOtherMarker = false;
    this.toString = function() {
        return 'RZoominTool';
    }
    this.setMaplet = function(maplet) {
        if (maplet.toString() != 'RMap') {
            window.status = '不能对' + this.toString() + '添加非RMap对象';
        }
        this.maplet = maplet;
    }
    this.tool.root = this;
    this.tool.onclick = function() {
        if (!this.root.maplet) {
            window.status = this.root.toString() + '尚未添加到有效的Toolbox。';
            return;
        }
        this.root.maplet.setZoomLevel(this.root.maplet.getZoomLevel() + 1);
        this.root.notify('onsuccess');
    }
    this.turnoff = function() {
        this.notify('onturnoff');
    }
    this.clear = function() { }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RZoomoutTool(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.maplet = null;
    this.isKeepOtherMarker = false;
    this.toString = function() {
        return 'RZoomoutTool';
    }
    this.setMaplet = function(maplet) {
        if (maplet.toString() != 'RMap') {
            window.status = '不能对' + this.toString() + '添加非RMap对象';
        }
        this.maplet = maplet;
    }
    this.tool.root = this;
    this.tool.onclick = function() {
        if (!this.root.maplet) {
            window.status = this.root.toString() + '尚未添加到有效的Toolbox。';
            return;
        }
        this.root.maplet.setZoomLevel(this.root.maplet.getZoomLevel() - 1);
        this.root.notify('onsuccess');
    }
    this.turnoff = function() {
        this.notify('onturnoff');
    }
    this.clear = function() { }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RMapmoveTool(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.isLock = true;
    if (tool.src) {
        this.imgpath = this.tool.src;
    }
    this.toString = function() {
        return 'RMapmoveTool';
    }
    this.maplet = null;
    this.turnon = function() {
        this.isLock = false;
        //		this.notify('onturnon');
        if (this.imgpath) {
            this.tool.src = this.imgpath;
        }
    }
    this.turnoff = function() {
        this.isLock = true;
        if (this.imgpath) {
            this.tool.src = '/img/MapmoveToolOff.gif';
        }
        //	    this.notify('onturnoff');
    }
    this.turnonClick = function() {
        this.isLock = false;
        this.notify('onturnon');
        if (this.imgpath) {
            this.tool.src = this.imgpath;
        }
    }
    this.tool.root = this;
    this.tool.onclick = function() {
        this.root.beginTool();
    }
    this.beginTool = function() {
        if (this.begined) { return; }
        //		this.notify('onbegin');
        this.begined = true;
    }
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
    }
    this.reset = function() {
        this.begined = false;
        //		this.notify('onreset');
    }
    this.clear = function() {
        //	    this.notify('onturnoff');
    }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onreset = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.onclicked = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onreset':
                if (listener.onreset) {
                    this.onreset[this.onreset.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onreset':
                for (var i = 0; i < this.onreset.length; i++) {
                    if (this.onreset[i].onreset) {
                        this.onreset[i].onreset();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RContextMenu(width) {
    this.menu = new RList(0, 0, width, 22);
    this.menu.isChangeClickColor = false;
    this.style = this.menu.style;
    this.style.border = '1px solid #AAAAAA';
    this.menu.style.overflowY = 'auto';
    this.toString = function() {
        return 'RContextMenu';
    }
    this.get = function() {
        return this.menu.get();
    }
    this.addMenuItem = function(text, value, title) {
        text = '&nbsp;' + text + '';
        this.menu.addListItem(text, value, title);
        this.menu.style.height = 20 * this.menu.getLength() + 2;
    }
    this.clear = function() {
        this.menu.clear();
    }
    this.addSeparator = function() {
        this.menu.addListItem('<hr width=' + (width - 4) + ' align="center">', '', '');
        this.menu.style.height = 20 * this.menu.getLength() + 2;
    }
    this.addMenuContent = function(content, value, title) {
        if (content.style) {
            content.style.align = 'center';
        }
        this.menu.addListContent(content, value, title);
        this.menu.style.height = 20 * this.menu.getLength() + 2;
    }
    this.setLeftTop = function(left, top) {
        this.menu.style.left = left;
        this.menu.style.top = top;
    }
    this.hide = function() {
        this.visible = false;
        this.menu.hide();
    }
    this.show = function() {
        this.visible = true;
        this.menu.show();
    }
    this.getSelectedValue = function() {
        return this.menu.selectedValue;
    }
    this.getSelectedIndex = function() {
        return this.menu.selectedIndex;
    }
    this.getSelectedText = function() {
        return this.menu.selectedText;
    }
    this.addListener = function(listener, estring) {
        this.menu.addListener(listener, estring);
    }
}
function RList(left, top, width, height) {
    this.selectedIndex = null;
    this.selectedText = null;
    this.selectedValue = null;
    this.highlightIndex = null;
    this.highlightText = null;
    this.highlightValue = null
    this.isMouseOver = false;
    this.isChangeClickColor = true;
    this.isChecking = true;
    this.div = new RDiv(left, top, width, height).get();
    this.style = this.div.style;
    this.div.style.backgroundColor = '#FFFFFF';
    this.div.style.overflowY = 'scroll';
    this.listData = new Array();
    this.table = new RTable().get();
    this.tbody = new RTBody().get();
    this.table.appendChild(this.tbody);
    this.div.appendChild(this.table);
    this.table.style.width = width - 19;
    this.toString = function() {
        return 'RList';
    }
    this.get = function() {
        return this.div;
    }
    this.addListContent = function(content, value, title) {
        this.addListItem('', value, title);
        this.listData[this.listData.length - 1].appendChild(content.get());
    }
    this.addListItem = function(text, value, title) {
        var td = new RTd().get();
        td.innerHTML = text;
        td.value = value;
        td.title = title;
        td.style.fontSize = 12;
        td.root = this;
        td.key = this.listData.length;
        td.checked = false;
        if (value != '') {
            td.style.cursor = 'pointer';
        } else {
            td.style.cursor = 'default';
        }
        td.style.backgroundColor = '#FFFFFF';
        this.listData[this.listData.length] = td;
        td.onmouseover = function() {
            if (this.value == '') { return; }
            this.root.highlight(this.key);
            this.root.isMouseOver = true;
            this.root.notify('onmouseover');
        }
        td.onmouseout = function() {
            if (this.value == '') { return; }
            if (!this.checked || !this.isChangeClickColor) {
                this.style.backgroundColor = '#FFFFFF';
            } else {
                this.style.backgroundColor = '#BBDD99';
            }
            this.root.isMouseOver = false;
            this.root.notify('onmouseout');
        }
        if (this.isChecking) {
            td.onclick = function() {
                if (this.value == '') { return; }
                this.root.check(this.key);
            }
        }
        var tr = new RTr().get();
        tr.appendChild(td);
        this.tbody.appendChild(tr);
        this.isChecking = true;
    }
    this.clear = function() {
        if (this.div.addEventListener) {
            this.tbody.textContent = '';
        } else {
            this.tbody.innerText = '';
        }
        this.listData = new Array();
        this.selectedIndex = -1;
        this.selectedValue = null;
        this.selectedText = '';
        this.highlightIndex = -1;
    }
    this.uncheckAll = function() {
        for (var listItr = 0; listItr < this.listData.length; listItr++) {
            this.listData[listItr].checked = false;
            this.listData[listItr].style.backgroundColor = '#FFFFFF';
        }
    }
    this.hide = function() {
        this.div.style.visibility = 'hidden';
    }
    this.show = function() {
        this.div.style.visibility = 'visible';
    }
    this.highlightnext = function() {
        if (this.highlightIndex == null) {
            this.highlightIndex = -1;
        }
        this.highlight(this.highlightIndex + 1);
    }
    this.highlightprev = function() {
        if (this.highlightIndex == null) {
            this.highlightIndex = 0;
        }
        this.highlight(this.highlightIndex - 1);
    }
    this.highlight = function(index) {
        index = index % this.listData.length;
        if (index >= 0 && index < this.listData.length) {
            this.delightAll();
            if (!this.listData[index].checked || !this.isChangeClickColor) {
                this.listData[index].style.backgroundColor = '#99BBDD';
            } else {
                this.listData[index].style.backgroundColor = '#AACC88';
            }
            this.highlightIndex = index;
            this.highlightText = this.listData[index].innerHTML;
            this.highlightValue = this.listData[index].value;
            listbounds = getBoundingClientRect(this.div);
            itembounds = getBoundingClientRect(this.listData[index]);
            if (listbounds.bottom < itembounds.bottom) {
                this.div.scrollTop += itembounds.bottom - listbounds.bottom + 3;
            } else if (listbounds.top > itembounds.top) {
                if ((this.div.scrollTop - (listbounds.top - itembounds.top + 3)) > 0) {
                    this.div.scrollTop -= listbounds.top - itembounds.top + 3;
                } else {
                    this.div.scrollTop = 0;
                }
            }
        }
    }
    this.check = function(index) {
        index = index % this.listData.length;
        if (index >= 0 && index < this.listData.length) {
            this.uncheckAll();
            if (this.isChangeClickColor) {
                this.listData[index].style.backgroundColor = '#BBDD99';
            }
            this.listData[index].checked = true;
            this.selectedIndex = this.listData[index].key;
            this.selectedText = this.listData[index].innerHTML;
            this.selectedValue = this.listData[index].value;
            this.notify('onselected');
            this.notify('onclicked');
        }
    }
    this.affect = function(index) {
        index = index % this.listData.length;
        if (index >= 0 && index < this.listData.length) {
            this.affectedIndex = this.listData[index].key;
            this.affectedText = this.listData[index].innerHTML;
            this.affectedValue = this.listData[index].value;
        }
    }
    this.checkhighlight = function() {
        this.check(this.highlightIndex);
    }
    this.delightAll = function() {
        for (var iItem = 0; iItem < this.listData.length; iItem++) {
            this.delight(iItem);
        }
    }
    this.delight = function(index) {
        index = index % this.listData.length;
        if (index >= 0 && index < this.listData.length) {
            if (this.listData[index].checked && this.isChangeClickColor) {
                this.listData[index].style.backgroundColor = '#BBDD99';
            } else {
                this.listData[index].style.backgroundColor = '#FFFFFF';
            }
        }
    }
    this.getLength = function() {
        return this.listData.length;
    }
    this.resize = function(width, height) {
        if (width) {
            this.style.width = width;
        }
        if (height) {
            this.style.height = height;
            this.table.style.width = width - 19;
        }
    }
    this.onclicked = new Array();
    this.onselected = new Array();
    this.onmouseover = new Array();
    this.onmouseout = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                }
                break;
            case 'onselected':
                if (listener.onselected) {
                    this.onselected[this.onselected.length] = listener;
                }
                break;
            case 'onmouseover':
                if (listener.onmouseover) {
                    this.onmouseover[this.onmouseover.length] = listener;
                }
                break;
            case 'onmouseout':
                if (listener.onmouseout) {
                    this.onmouseout[this.onmouseout.length] = listener;
                }
                break;
            default:
                window.status = this.toString() + '不存在事件：' + estring;
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        try {
                            this.onclicked[i].onclicked();
                        }
                        catch (e)
{ }
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onselected':
                for (var i = 0; i < this.onselected.length; i++) {
                    if (this.onselected[i].onselected) {
                        this.onselected[i].onselected();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onmouseover':
                for (var i = 0; i < this.onmouseover.length; i++) {
                    if (this.onmouseover[i].onmouseover) {
                        this.onmouseover[i].onmouseover();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onmouseout':
                for (var i = 0; i < this.onmouseout.length; i++) {
                    if (this.onmouseout[i].onmouseout) {
                        this.onmouseout[i].onmouseout();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            default:
                window.status = this.toString() + '抛出了一个未经定义的事件：' + estring;
                break;
        }
    }
}
function RTable() {
    this.table = document.createElement('Table');
    this.style = this.table.style;
    this.table.cellPadding = 0;
    this.table.cellSpacing = 0;
    this.get = function() {
        return this.table;
    }
    this.toString = function() {
        return 'RTable';
    }
    this.clearRows = function() {
        for (var iRow = 0; iRow < this.table.rows.length; iRow++) {
            this.table.deleteRow(this.table.rows[iRow]);
        }
    }
}
function RTBody() {
    this.tbody = document.createElement('TBody');
    this.style = this.tbody.style;
    this.get = function() {
        return this.tbody;
    }
    this.toString = function() {
        return 'RTBody';
    }
}
function RTr() {
    this.tr = document.createElement('tr');
    this.style = this.tr.style;
    this.get = function() {
        return this.tr;
    }
    this.toString = function() {
        return 'RTr';
    }
}
function RTd() {
    this.td = document.createElement('td');
    this.style = this.td.style;
    this.td.style.height = 20;
    this.td.style.vAlign = 'top';
    this.get = function() {
        return this.td;
    }
    this.toString = function() {
        return 'RTd';
    }
}
//<script language="javascript" src="rapi/rbase/RFunctions.js"></script>
function RSearchRoundBox(imgsrc) {
    this.imgsrc = imgsrc;
    this.toString = function() {
        return 'RSearchRoundBox';
    }
    ///具名常量
    this.MAX_RADIUS = 3500; //最大搜索的范围，单位：米
    this.MAX_RESULT_COUNT = 200; //最多显示搜索结果的信息点个数
    ///搜索周边的中心点经纬度
    this.centerLat = 23.00001;
    this.centerLng = 113.00001;
    this.searchRadius = 500;
    this.setCenterLat = function(nCenterLat) {
        this.centerLat = nCenterLat;
    }
    this.setCenterLng = function(nCenterLng) {
        this.centerLng = nCenterLng;
    }
    this.setSearchRadius = function(nSearchRadius) {
        if (nSearchRadius > 0 && nSearchRadius < this.MAX_RADIUS) {
            this.searchRadius = nSearchRadius;
        }
    }
    ///获得搜索的范围
    this.getSearchBounds = function() {
        if (this.radiusDropList.getValue() > 0) {
            this.searchRadius = this.radiusDropList.getValue();
        } else {
            this.searchRadius = this.MAX_RADIUS;
        }
        return getBoundsByCenterLatLngAndRadius(this.centerLat, this.centerLng, this.searchRadius);
    }
    ///获得需要搜索的关键字
    this.getSearchKeyword = function() {
        return trim(this.kwText.getText());
    }
    ///获得需要搜索的类别ID
    this.getSearchCategoryId = function() {
        return this.CategoryPicker.getCurrentCategoryId();
    }
    ///获得需要搜索的类别名称
    this.getSearchCategoryName = function() {
        return this.CategoryPicker.getCurrentCategoryName();
    }
    ///获得需要搜索结果的个数
    this.getSearchResultCount = function() {
        if (this.resultCountDropList.getValue() > 0) {
            return this.resultCountDropList.getValue()
        } else {
            return this.MAX_RESULT_COUNT;
        }
    }
    ///背景的大小
    this.bgWidth = 1024;
    this.bgHeight = 568;
    ///搜索框的大小
    this.innerWidth = 380;
    this.innerHeight = 200;
    ///搜索的位置
    this.innerLeft = this.bgWidth / 3;
    this.innerTop = this.bgHeight / 3;
    //------begin 页面添加元素-------------
    ///背景的DIV
    this.bgDiv = new RDiv(0, 0, null, null).get();
    this.bgStyle = this.bgDiv.style;
    ///内部的DIV
    this.innerDiv = new RDiv(0, 0, null, null).get();
    this.innerStyle = this.innerDiv.style;
    this.bgDiv.appendChild(this.innerDiv);
    ///添加分类的下拉列表
    this.CategoryPicker = new RCategoryPicker(0, 3);
    this.categoryStyle = this.CategoryPicker.style;
    this.bgDiv.appendChild(this.CategoryPicker.get());
    ///添加关闭按纽到DIV中
    if (!this.closeBtn) {
        this.closeBtn = new RImage(this.innerWidth, 13, this.imgsrc + '/close.gif').get();
    }
    this.closeBtn.style.cursor = 'pointer';
    this.closeBtn.root = this;
    this.bgDiv.appendChild(this.closeBtn);
    ///点击关闭事件
    this.closeBtn.onclick = function() {
        this.root.hide();
    }
    //添加搜索按纽到DIV中
    if (!this.submitBtn) {
        this.submitBtn = new RButton(0, 0, 56, 24, '搜索');
    }
    this.submitBtn.get().root = this;
    this.bgDiv.appendChild(this.submitBtn.get());
    this.submitBtn.get().onclick = function() {
        this.root.notify('onBoxClicked');
        this.root.hide();
    }
    ///添加关键字搜索框到DIV中
    if (!this.kwText) {
        this.kwText = new RTextField(0, 0, 250, '');
        this.kwText.setAcceptButton(this.submitBtn.get());
    }
    this.bgDiv.appendChild(this.kwText.get());
    ///添加周边范围大小下拉列表（单位：米）
    if (!this.radiusDropList) {
        this.radiusDropList = new RDropList(0, 0, 50, null);
        this.radiusDropList.addListItem('不限', -1);
        for (var cRadius = 100; cRadius <= this.MAX_RADIUS; ) {
            this.radiusDropList.addListItem(cRadius, cRadius);
            cRadius *= 2;
        }
    }
    this.bgDiv.appendChild(this.radiusDropList.get());
    ///添加搜索结果显示个数下拉列表（单位：个）
    if (!this.resultCountDropList) {
        this.resultCountDropList = new RDropList(0, 0, 50, null);
        this.resultCountDropList.addListItem('不限', -1);
        for (var cCount = 5; cCount <= this.MAX_RESULT_COUNT; ) {
            this.resultCountDropList.addListItem(cCount, cCount);
            cCount *= 2;
        }
    }
    this.bgDiv.appendChild(this.resultCountDropList.get());
    //------end  页面添加元素-------------
    this.setInnerHTML = function() {
        this.setAllElementLocation();
        this.innerDiv.innerHTML = '<table style="width: ' + this.bgWidth + 'px; height: ' + this.bgHeight + 'px;"><tr><td style="z-index: 2000; background-color: Menu; filter: alpha(opacity=70);border-right: activecaption thick ridge; border-top: activecaption thick ridge;border-left: activecaption thick ridge; border-bottom: activecaption thick ridge;"><table><tr><td valign="top" style="z-index: 2000; background-color: Menu; filter: alpha(opacity=70);width: ' + this.innerWidth + 'px; height: ' + this.innerHeight + 'px;position:absolute;left:' + this.innerLeft + ';top:' + this.innerTop + '; border-right: activecaption thick ridge; border-top: activecaption thick ridge;border-left: activecaption thick ridge; border-bottom: activecaption thick ridge;"><table><tr style="height:40px" valign="middle" ><td>分&nbsp;&nbsp;类：</td></tr><tr style="height:40px" valign="middle" ><td>关键字：</td></tr><tr style="height:40px" valign="middle" ><td>范&nbsp;&nbsp;围：&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;米<span style="color: #999999">&nbsp; 请选择你希望搜索的半径范围！</span></td></tr><tr style="height:40px" valign="middle" ><td>个&nbsp;&nbsp;数：&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;个<span style="color: #999999">&nbsp; 请设置搜索结果显示的信息点个数！</span></td></tr></table></td></tr></table></td></tr></table>';
    }
    ///获得整个搜索框的DIV
    this.get = function() {
        return this.bgDiv;
    }
    ///重新布局所有元素；必须是先确定版面（背景与搜索框），再可以确定其他元素的布局
    this.setAllElementLocation = function() {
        if (this.closeBtn) {
            if (this.innerLeft + this.innerWidth - 8 > 0) {
                this.closeBtn.style.left = this.innerLeft + this.innerWidth - 8;
            }
            this.closeBtn.style.top = this.innerTop + 6;
        }
        if (this.submitBtn) {
            if (this.innerLeft + this.innerWidth - 60 > 0) {
                this.submitBtn.style.left = this.innerLeft + this.innerWidth - 60;
            }
            this.submitBtn.style.top = this.innerTop + 58;
        }
        if (this.kwText) {
            if (this.innerLeft + 60 > 0) {
                this.kwText.style.left = this.innerLeft + 60;
            }
            this.kwText.style.top = this.innerTop + 60;
        }
        if (this.radiusDropList) {
            if (this.innerLeft + 60 > 0) {
                this.radiusDropList.style.left = this.innerLeft + 60;
            }
            this.radiusDropList.style.top = this.innerTop + 100;
        }
        if (this.resultCountDropList) {
            if (this.innerLeft + 60 > 0) {
                this.resultCountDropList.style.left = this.innerLeft + 60;
            }
            this.resultCountDropList.style.top = this.innerTop + 140;
        }
        this.categoryStyle.left = this.innerLeft + 60;
        this.categoryStyle.top = this.innerTop + 20;
        if (this.innerWidth - 60 > 0) {
            this.categoryStyle.width = this.innerWidth - 60;
        }
        this.categoryStyle.height = this.innerHeight;
    }
    ///设置搜索框的位置
    this.setBoxLocation = function(nBoxLeft, nBoxTop) {
        this.bgStyle.left = 0;
        this.bgStyle.top = 0;
        if (nBoxLeft && nBoxLeft > 0 && nBoxLeft < this.bgWidth) {
            this.innerLeft = nBoxLeft;
        }
        if (nBoxTop && nBoxTop > 0 && nBoxTop < this.bgHeight) {
            this.innerTop = nBoxTop;
        }
        this.setInnerHTML();
    }
    ///设置搜索框的大小,背景的大小
    this.setBoxSize = function(nBoxWidth, nBoxHeight, nBgWidth, nBgHeight) {
        if (nBgWidth && nBgWidth > 0) {
            this.bgWidth = nBgWidth;
        }
        if (nBgHeight && nBgHeight > 0) {
            this.bgHeight = nBgHeight;
        }
        if (nBoxWidth && nBoxWidth > 0 && nBoxWidth < nBgWidth) {
            this.innerWidth = nBoxWidth;
        }
        if (nBoxHeight && nBoxHeight > 0 && nBoxHeight < nBgHeight) {
            this.innerHeight = nBoxHeight;
        }
        this.setInnerHTML();
    }
    this.resize = function(nBgWidth, nBgHeight) {
        if (nBgWidth >= 0 && nBgHeight >= 0) {
            //	    alert(nBgWidth);
            //	    alert(nBgHeight);
            this.setBoxSize(null, null, nBgWidth, nBgHeight);
            this.setBoxLocation(Math.floor(nBgWidth / 3), Math.floor(nBgHeight / 3));
        }
        this.notify('onBoxResized');
    }
    ///隐藏整个搜索框
    this.hide = function() {
        this.bgStyle.visibility = 'hidden';
        this.notify('onBoxClosed');
    }
    ///显示整个搜索框
    this.show = function() {
        this.bgStyle.visibility = 'visible';
        this.setInnerHTML();
        this.notify('onBoxOpened');
    }
    ///添加各种响应事件
    //响应盒子关闭事件
    this.onBoxClosed = new Array();
    //响应盒子打开事件
    this.onBoxOpened = new Array();
    //响应按纽确定事件
    this.onBoxClicked = new Array();
    //响应盒子重新调整大小事件
    this.onBoxResized = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onBoxClosed':
                if (listener.onBoxClosed) {
                    this.onBoxClosed[this.onBoxClosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onBoxOpened':
                if (listener.onBoxOpened) {
                    this.onBoxOpened[this.onBoxOpened.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onBoxClicked':
                if (listener.onBoxClicked) {
                    this.onBoxClicked[this.onBoxClicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onBoxResized':
                if (listener.onBoxResized) {
                    this.onBoxResized[this.onBoxResized.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onBoxClosed':
                for (var i = 0; i < this.onBoxClosed.length; i++) {
                    if (this.onBoxClosed[i].onBoxClosed) {
                        this.onBoxClosed[i].onBoxClosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onBoxOpened':
                for (var i = 0; i < this.onBoxOpened.length; i++) {
                    if (this.onBoxOpened[i].onBoxOpened) {
                        this.onBoxOpened[i].onBoxOpened();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onBoxClicked':
                for (var i = 0; i < this.onBoxClicked.length; i++) {
                    if (this.onBoxClicked[i].onBoxClicked) {
                        this.onBoxClicked[i].onBoxClicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onBoxResized':
                for (var i = 0; i < this.onBoxResized.length; i++) {
                    if (this.onBoxResized[i].onBoxResized) {
                        this.onBoxResized[i].onBoxResized();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    ///初始化时先是隐藏整个界面
    this.hide();
    this.getCenterLatLng = function() {
        return new RLatLng(this.centerLat, this.centerLng);
    }
}
function RButton(left, top, width, height, text) {
    this.button = document.createElement('Input');
    this.style = this.button.style;
    this.button.type = "button";
    this.button.value = text;
    this.style.position = 'absolute';
    this.style.fontSize = '12px';
    this.style.left = left;
    this.style.top = top;
    this.style.width = width;
    this.style.height = height;
    this.toString = function() {
        return 'RButton';
    }
    this.get = function() {
        return this.button;
    }
}
function RTextField(left, top, width, value) {
    this.defaultvalue = value;
    this.textfield = document.createElement('Input');
    this.style = this.textfield.style;
    this.oldValue = value;
    this.style.position = 'absolute';
    this.style.left = left;
    this.style.top = top;
    this.style.border = '1px solid #9AAFC2';
    this.style.backgroundColor = '#FCFCFC';
    this.textfield.type = 'text';
    this.textfield.value = value;
    this.textfield.width = width;
    this.textfield.height = 18;
    this.textfield.size = Math.round(width / 6);
    this.recentdownkey = -1;
    this.recentupkey = -1;
    this.keyCount = 0;
    this.textfield.root = this;
    this.textfield.onblur = function() {
        if (this.root.oldValue != this.value) {
            this.root.notify('ontextchanged');
        }
        if (this.root.defaultvalue && this.root.defaultvalue != '') {
            if (this.value == '') {
                this.value = this.root.defaultvalue;
            }
        }
        this.root.notify('onleave');
    }
    this.textfield.onkeyup = function() {
        this.root.keyCount++;
        setRTimeout(this.root, this.root.isKeyStopped, 1500, [this.root.keyCount]);
        if (this.value != this.root.oldValue) {
            this.root.oldValue = this.value;
            this.root.notify('ontextchanged');
        }
        this.recentupkey = event.keyCode;
        this.root.notify('onkeyup');
    }
    this.isKeyStopped = function(keyCount) {
        if (this.keyCount == keyCount) {
            this.keyCount = 0;
            this.notify('onkeystopped');
        }
    }
    this.textfield.onfocus = function() {
        if (this.value == this.root.defaultvalue) {
            this.value = '';
        }
    }
    this.textfield.onkeydown = function() {
        this.recentkey = event.keyCode;
        if (this.recentkey == 38) {
            this.root.notify('onarrayup');
        } else if (this.recentkey == 40) {
            this.root.notify('onarraydown');
        } else if (this.recentkey == 13) {
            if (this.root.acceptButton) {
                this.root.acceptButton.onclick();
            }
            this.root.notify('onenter');
        }
        this.root.notify('onkeydown');
    }
    this.get = function() {
        return this.textfield;
    }
    this.toString = function() {
        return 'RTextField';
    }
    this.getValue = function() {
        return this.textfield.value;
    }
    this.setText = function(text) {
        if (this.textfield.value != text) {
            this.textfield.value = text;
            this.notify('ontextchanged');
        }
    }
    this.getText = function() {
        return this.textfield.value;
    }
    this.setAcceptButton = function(btn) {
        if (btn.onclick) {
            this.acceptButton = btn;
        }
    }
    this.onkeystopped = new Array();
    this.onleave = new Array();
    this.ontextchanged = new Array();
    this.onkeydown = new Array();
    this.onkeyup = new Array();
    this.onarraydown = new Array();
    this.onarrayup = new Array();
    this.onenter = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onkeystopped':
                if (listener.onkeystopped) {
                    this.onkeystopped[this.onkeystopped.length] = listener;
                }
                break;
            case 'ontextchanged':
                if (listener.ontextchanged) {
                    this.ontextchanged[this.ontextchanged.length] = listener;
                }
                break;
            case 'onleave':
                if (listener.onleave) {
                    this.onleave[this.onleave.length] = listener;
                }
                break;
            case 'onkeydown':
                if (listener.onkeydown) {
                    this.onkeydown[this.onkeydown.length] = listener;
                }
                break;
            case 'onkeyup':
                if (listener.onkeyup) {
                    this.onkeyup[this.onkeyup.length] = listener;
                }
                break;
            case 'onarraydown':
                if (listener.onarraydown) {
                    this.onarraydown[this.onarraydown.length] = listener;
                }
                break;
            case 'onarrayup':
                if (listener.onarrayup) {
                    this.onarrayup[this.onarrayup.length] = listener;
                }
                break;
            case 'onenter':
                if (listener.onenter) {
                    this.onenter[this.onenter.length] = listener;
                }
                break;
            default:
                window.status = this.toString() + '不存在事件：' + estring;
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onkeystopped':
                for (var i = 0; i < this.onkeystopped.length; i++) {
                    if (this.onkeystopped[i].onkeystopped) {
                        this.onkeystopped[i].onkeystopped();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'ontextchanged':
                for (var i = 0; i < this.ontextchanged.length; i++) {
                    if (this.ontextchanged[i].ontextchanged) {
                        this.ontextchanged[i].ontextchanged();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onleave':
                for (var i = 0; i < this.onleave.length; i++) {
                    if (this.onleave[i].onleave) {
                        this.onleave[i].onleave();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onkeydown':
                for (var i = 0; i < this.onkeydown.length; i++) {
                    if (this.onkeydown[i].onkeydown) {
                        this.onkeydown[i].onkeydown();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onkeyup':
                for (var i = 0; i < this.onkeyup.length; i++) {
                    if (this.onkeyup[i].onkeyup) {
                        this.onkeyup[i].onkeyup();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onarraydown':
                for (var i = 0; i < this.onarraydown.length; i++) {
                    if (this.onarraydown[i].onarraydown) {
                        this.onarraydown[i].onarraydown();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onarrayup':
                for (var i = 0; i < this.onarrayup.length; i++) {
                    if (this.onarrayup[i].onarrayup) {
                        this.onarrayup[i].onarrayup();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onenter':
                for (var i = 0; i < this.onenter.length; i++) {
                    if (this.onenter[i].onenter) {
                        this.onenter[i].onenter();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            default:
                window.status = this.toString() + '抛出了一个未经定义的事件：' + estring;
                break;
        }
    }
}
///Author:Jancion;Time:070615
function RCategoryPicker(rootCategoryId, maxLevel) {
    this.toString = function() {
        return 'RCategoryPicker';
    }
    this.rootCategoryId = rootCategoryId;
    this.maxLevel = maxLevel;
    this.engine = new RSearchEngine(JS_SERVER + 'GetXml.aspx');
    this.droplists = new Array();
    this.categories = new Array();
    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    this.categoryId = new Array();
    this.level = 0;
    this.pickerWidth = null;
    this.setPickerWidth = function(nWidth) {
        if (nWidth > 50) {
            this.pickerWidth = nWidth;
        }
    }
    this.initPicker = function(rootId) {
        if (rootId != -2) {
            if (this.level < this.maxLevel) {
                this.loading = true;
                this.level++;
                this.engine.getSubCategories(rootId, this, this.categoryCallBack);
            } else {
                this.loading = false;
            }
        }
    }
    this.categoryCallBack = function() {
        var xmlHttp = this.engine.getXmlHttp();
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
            if (xmlHttp.status == 200) {
                var xmldoc = xmlHttp.responseXML;
                var codenodes = xmldoc.getElementsByTagName("TYPEID");
                var pcodenodes = xmldoc.getElementsByTagName("PARENTID");
                var namenodes = xmldoc.getElementsByTagName("TYPE_NAME");
                if (codenodes.length == 0) {
                    while (this.droplists.length > this.level - 1) {
                        var droplist = this.droplists.pop();
                        droplist.clear();
                        this.div.removeChild(droplist.get());
                    }
                    this.loading = false;
                } else {
                    var droplist;
                    if (!this.droplists[this.level - 1]) {
                        droplist = new RDropList(0, 0, this.pickerWidth, null);
                        droplist.style.position = 'static';
                        this.droplists.push(droplist);
                        droplist.level = this.droplists.length;
                        this.div.appendChild(droplist.get());
                    } else {
                        droplist = this.droplists[this.level - 1];
                        droplist.clear();
                    }
                    droplist.addListItem("全部类别", -1);
                    for (var iCode = 0; iCode < codenodes.length; iCode++) {
                        var code = codenodes[iCode].firstChild.nodeValue;
                        var pcode = pcodenodes[iCode].firstChild.nodeValue;
                        var name = namenodes[iCode].firstChild.nodeValue;
                        droplist.addListItem(name, code);
                    }
                    if (this.rootCategoryId == -2) {
                        this.droplists[this.level - 1].select.value = this.categoryId[this.level].toString(10);
                        this.droplists[this.level - 1].selectedValue = this.categoryId[this.level].toString(10);
                    }
                    var listlistener = new Object();
                    listlistener.root = this;
                    listlistener.target = droplist;
                    listlistener.onselectchanged = function() {
                        this.root.level = this.target.level;
                        this.root.initPicker(this.target.selectedValue);
                        setRTimeout(this.root, this.root.notifychanged, 100);
                    }
                    droplist.addListener(listlistener, 'onselectchanged');
                    if (this.rootCategoryId == -2) {
                        this.initDefaultDistrictById();
                    } else {
                        this.initPicker(droplist.selectedValue);
                    }
                }
            }
        }
    }
    this.initPicker(this.rootCategoryId);
    this.initDefaultDistrictById = function() {
        if (this.level < this.categoryId.length - 1) {
            this.loading = true;
            this.level++;
            this.engine.getSubCategories(this.categoryId[this.level - 1], this, this.categoryCallBack);
        } else {
            this.loading = false;
            this.categoryId = new Array();
            this.rootCategoryId = 0;
        }
    }
    this.setDefaultDistrictById = function(categoryId) {
        this.categoryId = categoryId;
        this.initDefaultDistrictById();
    }
    this.setDefaultCategoryByName = function(CategoryName) {
    }
    this.getCurrentCategoryName = function() {
        if (this.droplists[this.droplists.length - 1].selectedText == "全部类别" && this.droplists.length != 1) {
            return this.droplists[this.droplists.length - 2].selectedText;
        }
        return this.droplists[this.droplists.length - 1].selectedText;
    }
    this.getCurrentCategoryFullName = function() {
        var fullname = '';
        for (var iList = 0; iList < this.droplists.length; iList++) {
            if (this.droplists[iList].selectedText != "全部类别") {
                fullname += this.droplists[iList].selectedText;
            }
        }
        return fullname;
    }
    this.getCurrentCategoryId = function() {
        if (this.droplists[this.droplists.length - 1] != null) {
            if (this.droplists[this.droplists.length - 1].selectedValue != -1) {
                return this.droplists[this.droplists.length - 1].selectedValue;
            }
            else {
                if (this.droplists.length < 2) {
                    if (this.droplists[this.droplists.length - 1].selectedValue == -1) {
                        return 0;
                    }
                    else {
                        return this.droplists[this.droplists.length - 1].selectedValue;
                    }
                }
                else {
                    return this.droplists[this.droplists.length - 2].selectedValue;
                }
            }
        } else {
            return 0;
        }
    }
    this.getCategoryById = function(id) {
        for (var iCategory = 0; iCategory < this.categories.length; iCategory++) {
            if (this.categories[iCategory] == id) {
                return this.categories[iCategory];
            }
        }
        return null;
    }
    this.get = function() {
        return this.div;
    }
    this.onCategoryChanged = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onCategoryChanged':
                if (listener.onCategoryChanged) {
                    this.onCategoryChanged[this.onCategoryChanged.length] = listener;
                } else {
                    window.status = this.toString() + ":不合法的" + estring + "事件对象";
                }
                break;
            default:
                window.status = this.toString() + "类不存在" + estring + "事件";
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onCategoryChanged':
                for (var i = 0; i < this.onCategoryChanged.length; i++) {
                    if (this.onCategoryChanged[i].onCategoryChanged) {
                        this.onCategoryChanged[i].onCategoryChanged();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notifychanged = function() {
        if (this.loading) {
            setRTimeout(this, this.notifychanged, 100);
        } else {
            this.notify('onCategoryChanged');
        }
    }
}
function RDropList(left, top, width, size) {
    this.listItems = new Array();
    this.select = document.createElement('Select');
    this.style = this.select.style;
    this.size = 0;
    if (size) {
        this.size = size;
    }
    this.style.position = 'absolute';
    this.style.visibility = 'inherit';
    this.style.left = left;
    this.style.top = top;
    this.style.width = width;
    this.style.fontSize = 12;
    this.select.size = this.size;
    this.selectedIndex = -1;
    this.selectedValue = null;
    this.selectedText = '';
    this.toString = function() {
        return 'RDropList';
    }
    this.get = function() {
        return this.select;
    }
    this.addListItem = function(text, value) {
        var op = document.createElement('Option');
        op.text = text;
        op.value = value;
        op.richvalue = value;
        this.listItems[this.listItems.length] = op;
        this.select.options.add(op);
        if (this.select.options.length == 1) {
            this.selectedText = text;
            this.selectedValue = value;
            this.selectedIndex = this.select.selectedIndex;
            this.select.value = value
        }
    }
    this.clear = function() {
        for (var i = 0; i < this.listItems.length; i++) {
            this.select.options.remove(this.listItems[i]);
        }
        this.listItems = new Array();
    }
    this.getValue = function() {
        if (this.select.selectedIndex == -1) {
            return null;
        }
        return this.select.options[this.select.selectedIndex].value;
    }
    this.getRichValue = function() {
        if (this.select.selectedIndex == -1) {
            return null;
        }
        return this.select.options[this.select.selectedIndex].richvalue;
    }
    this.getText = function() {
        return this.select.options[this.select.selectedIndex].text;
    }
    this.select.root = this;
    this.select.onchange = function() {
        if (this.root.selectedIndex == this.selectedIndex) {
            return;
        } else {
            this.root.selectedIndex = this.selectedIndex;
            this.root.selectedText = this.options[this.selectedIndex].text;
            this.root.selectedValue = this.options[this.selectedIndex].richvalue;
            this.root.notify('onselectchanged');
        }
    }
    this.onselectchanged = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onselectchanged':
                if (listener.onselectchanged) {
                    this.onselectchanged[this.onselectchanged.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onselectchanged':
                for (var i = 0; i < this.onselectchanged.length; i++) {
                    if (this.onselectchanged[i].onselectchanged) {
                        this.onselectchanged[i].onselectchanged();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RSearchEngine(serviceUrl) {
    this.serviceUrl = serviceUrl;
    this.xmlHttp = new RXmlHttpRequest().get();
    this.searchPointByRegion = function(x1, y1, x2, y2, orderby, cat, lvl, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=co1&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&orderby=' + orderby + '&cat=' + cat + '&lvl=' + lvl + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() {
                callback.apply(target);
            }
        }
        else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //根据行政区号和搜索类别获取搜索关键字
    this.getKeywordTips = function(cityid, type, target, callback) {
        var url = this.serviceUrl + '?act=tips&cityid=' + escape(cityid) + '&type=' + escape(type);
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchPointByTel = function(tel, zone, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=tel&tel=' + escape(tel) + '&zone=' + escape(zone) + '&count=' + count + '&skip=' + skip;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    ///通过区号获得该区号对应地区的中心经纬度(进行定位)（在用）
    this.searchLocationByZone = function(zone, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=zone&zone=' + escape(zone) + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    ///通过电话号码与区号获得该关联的信息点集合（在用）
    this.searchPointByTelZone = function(tel, zone, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=telzone1&tel=' + escape(tel) + '&zone=' + escape(zone) + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    ///通过邮政编号获得对应地区的中心经纬度(进行定位)（在用）
    this.searchLocationByPostalcode = function(postalcode, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=postalcode&postalcode=' + escape(postalcode) + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchLocationByAutoId = function(AutoId, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=postalcode&AutoId=' + escape(AutoId) + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //通过搜索广告类型
    this.searchByAD = function(x1, y1, x2, y2, cat, cityid, count, target, callback) {
        var url = this.serviceUrl + '?act=ad&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&cat=' + escape(cat) + '&cityid=' + cityid + '&count=' + count;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchADByKeyword = function(x1, y1, x2, y2, keyword, cityid, count, target, callback) {
        var url = this.serviceUrl + '?act=ad&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&kw=' + escape(keyword) + '&cityid=' + cityid + '&count=' + count;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //	this.searchSADByRegion=function(x1,y1,x2,y2,cat,count,skip,lvl,target,callback){
    //		var url=this.serviceUrl+'?act=ad&x1='+x1+'&y1='+y1+'&x2='+x2+'&y2='+y2+'&adtype=1&count='+count+'&skip='+skip+'&lvl='+lvl+'&cat='+cat;
    //		//window.location=url;
    //		if(target){
    //			this.xmlHttp.onreadystatechange=function(){callback.apply(target);};
    //		}else{
    //			this.xmlHttp.onreadystatechange=callback;
    //		}
    //		this.xmlHttp.open('GET',url,true);
    //		this.xmlHttp.send(null);
    //	}
    ///通过道路搜索（进行具体道路定位）（在用）
    this.searchLocationByRoad = function(road, cityid, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=road&road=' + escape(road) + '&cityid=' + cityid + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchLocationByRoadid = function(roadid, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=road&roadid=' + escape(roadid) + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    ///通过地址搜索获得该关联的信息点集合
    this.searchPointByAddress = function(address, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=address&address=' + escape(address) + '&count=' + count + '&skip=' + skip;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    ///通过关键字模糊搜索GPSID
    this.searchGpsidByKeyword = function(keyword, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=gpsid&kw=' + escape(keyword) + '&count=' + count + '&skip=' + skip;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //通过GPSID定位相关信息
    this.locationGpsid = function(Gpsid, target, callback) {
        var url = this.serviceUrl + '?act=gpsid&gpsid=' + escape(Gpsid);
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //通过GPSID的ID获取GPSID关键的POI
    //	this.getPointByGpsid_id=function(id,target,callback){
    //		var url=this.serviceUrl+'?act=gpsid&id='+ escape( id );
    //		//window.location=url;
    //		if(target){
    //			this.xmlHttp.onreadystatechange=function(){callback.apply(target);};
    //		}else{
    //			this.xmlHttp.onreadystatechange=callback;
    //		}
    //		this.xmlHttp.open('GET',url,true);
    //		this.xmlHttp.send(null);
    //	}
    this.getPointByGpsid_id = function(gpsid, type, target, callback) {
        var url = this.serviceUrl + '?act=gpsid&gpsid=' + escape(gpsid) + '&type=' + escape(type);
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //通过名称搜索线路
    this.searchLineByName = function(keyword, cityid, searchType, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=line&kw=' + escape(keyword) + '&cityid=' + cityid + '&type=' + searchType + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //通过线路ID和线路类型获取线路详情
    this.getStationsByLineIdType = function(lineId, transportType, target, callback) {
        var url = this.serviceUrl + '?act=line&id=' + escape(lineId) + '&type=' + transportType;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //根据经纬度确定当前城市
    this.getCityByLatLng = function(lat, lng, target, callback) {
        var url = this.serviceUrl + '?act=getcity&lat=' + lat + '&lng=' + lng;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //通过关键字和区域查询信息点（在用）
    this.searchPointByRegionKeyword = function(x1, y1, x2, y2, kw, orderby, cat, lvl, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=co1&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&kw=' + escape(kw) + '&orderby=' + orderby + '&cat=' + cat + '&lvl=' + lvl + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchPointByCityKeyword = function(cityid, kw, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=co1&cityid=' + escape(cityid) + '&kw=' + escape(kw) + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //根据关键字和城市查询地名（在用）
    this.searchPlacenameByCity = function(cityid, kw, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=placename&cityid=' + escape(cityid) + '&kw=' + escape(kw) + '&count=' + count + '&skip=' + skip;
        //		window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    ///周边搜索
    //@1:起点经度
    //@2:起点纬度
    //@3:终点经度
    //@4:终点纬度
    //@5:关键字
    //@6:信息分类ID
    //@7:地图显示等级
    //@8:每页显示个数
    //@9:每页开始的索引
    //@10:总共最大搜索的条数
    this.searchPointByRound = function(x1, y1, x2, y2, kw, cat, lvl, step, skip, totalCount, target, callback) {
        var url = this.serviceUrl + '?act=round1&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&kw=' + escape(kw) + '&cat=' + cat + '&lvl=' + lvl + '&count=' + step + '&skip=' + skip + '&totalCount=' + totalCount;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchAroundPoint = function(ckw, kw, cityid, radius, step, skip, target, callback) {
        var url = this.serviceUrl + '?act=around1&ckw=' + escape(ckw) + '&kw=' + escape(kw) + '&cityid=' + cityid + '&radius=' + radius + '&count=' + step + '&skip=' + skip;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchForumByRegion = function(x1, y1, x2, y2, cat, lvl, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=forum&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&cat=' + cat + '&lvl=' + lvl + '&count=' + count + '&skip=' + skip;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchThematicMBPByRegion = function(x1, y1, x2, y2, cat, lvl, target, callback) {
        var url = this.serviceUrl + '?act=themembp&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&cat=' + cat + '&lvl=' + lvl;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.getThematicRegion = function() {
        var url = this.serviceUrl + '?act=region&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&cat=' + cat + '&lvl=' + lvl;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchPointByKeyword = function(kw, cityid, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=co1&kw=' + escape(kw) + '&cityid=' + cityid + '&count=' + count + '&skip=' + skip;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchPointByKeywordF = function(kw, cityid, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=kname&kw=' + escape(kw) + '&cityid=' + cityid + '&count=' + count + '&skip=' + skip;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchLocationByKeyword = function(kw, city, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=loc&kw=' + escape(kw) + '&cityid=' + city + '&count=' + count + '&skip=' + skip;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchStationByKeyword = function(kw, cityid, count, skip, target, callback) {
        var url = this.serviceUrl + '?act=station&kw=' + escape(kw) + '&cityid=' + cityid + '&count=' + count + '&skip=' + skip;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchMADByRegion = function(x1, y1, x2, y2, count, skip, lvl, target, callback) {
        var url = this.serviceUrl + '?act=ad&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&adtype=0&count=' + count + '&skip=' + skip + '&lvl=' + lvl;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchSelfNavigateRoute = function(x1, y1, x2, y2, type, target, callback) {
        var url = this.serviceUrl + '?act=nv&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&type=' + type;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchMassTransportRoute = function(x1, y1, x2, y2, cityid, type, target, callback) {
        var url = this.serviceUrl + '?act=mt&x1=' + x1 + '&y1=' + y1 + '&x2=' + x2 + '&y2=' + y2 + '&cityid=' + cityid + '&type=' + type;
        //window.location=url;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.searchPointById = function(type, id, target, callback) {
        var url = this.serviceUrl + '?act=poi&type=' + type + '&id=' + id;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.getSubCategories = function(id, target, callback) {
        var url = this.serviceUrl + '?act=cat&id=' + id;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.getProductionCategories = function(id, target, callback) {
        var url = this.serviceUrl + '?act=pcat&id=' + id;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.getForumType = function(id, target, callback) {
        var url = this.serviceUrl + '?act=forumtype&id=' + id;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.getChildDistricts = function(id, target, callback) {
        var url = this.serviceUrl + '?act=district&id=' + id;
        //window.location=url;
        //debugger;
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.getOpenedCities = function(target, callback) {
        var url = this.serviceUrl + '?act=opencity';
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.setCitySession = function(cityid, cityname, target, callback) {
        var url = this.serviceUrl + '?act=citysession&cityid=' + cityid + '&cityname=' + escape(cityname);
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    //获取服务器上的城市session设置
    this.getCitySession = function(target, callback) {
        var url = this.serviceUrl + '?act=getcitysession';
        if (target) {
            this.xmlHttp.onreadystatechange = function() { callback.apply(target); };
        } else {
            this.xmlHttp.onreadystatechange = callback;
        }
        this.xmlHttp.open('GET', url, true);
        this.xmlHttp.send(null);
    }
    this.getXmlHttp = function() {
        return this.xmlHttp;
    }
    this.toString = function() {
        return 'RSearchEngine';
    }
    this.convertPointResponse = function(xmldoc) {
        var mbps = new Array();
        try {
            xmldoc.getElementsByTagName("abc");
        }
        catch (e) {
            return mbps;
        }
        var idnodes = xmldoc.getElementsByTagName("PointID");
        var namenodes = xmldoc.getElementsByTagName("PointName");
        var addrnodes = xmldoc.getElementsByTagName("PointAddress");
        var telnodes = xmldoc.getElementsByTagName("Telephone");
        var zonenodes = xmldoc.getElementsByTagName("TelZoneNo");
        var postalcodenodes = xmldoc.getElementsByTagName("postalcode");
        var picnodes = xmldoc.getElementsByTagName("Picture");
        var mailnodes = xmldoc.getElementsByTagName("EMail");
        var urlnodes = xmldoc.getElementsByTagName("URL");
        var faxnodes = xmldoc.getElementsByTagName("Fax");
        var latnodes = xmldoc.getElementsByTagName("Latitude");
        var lngnodes = xmldoc.getElementsByTagName("Longitude");
        var topidnodes = xmldoc.getElementsByTagName("TopTypeID");
        var topnamenodes = xmldoc.getElementsByTagName("TopTypeName");
        var secondidnodes = xmldoc.getElementsByTagName("SecondTypeID");
        var secondnamenodes = xmldoc.getElementsByTagName("SecondTypeName");
        var thirdidnodes = xmldoc.getElementsByTagName("ThirdTypeID");
        var thirdnamenodes = xmldoc.getElementsByTagName("ThirdTypeName");
        var cantoncodenodes = xmldoc.getElementsByTagName("CantonCode");
        var cantonnamenodes = xmldoc.getElementsByTagName("CantonName");
        var parentcodenodes = xmldoc.getElementsByTagName("ParentCantonCode");
        var parentnamenodes = xmldoc.getElementsByTagName("ParentCantonName");
        var grandcodenodes = xmldoc.getElementsByTagName("GrandParentCantonCode");
        var grandnamenodes = xmldoc.getElementsByTagName("GrandParentCantonName");
        var typenodes = xmldoc.getElementsByTagName("Type");
        var claimnodes = xmldoc.getElementsByTagName("HasClaimed");
        var refernodes = xmldoc.getElementsByTagName("Refer");
        var promotionnodes = xmldoc.getElementsByTagName("PROMOTION");
        var businessscopenodes = xmldoc.getElementsByTagName("businessscope");
        for (var iNode = 0; iNode < idnodes.length; iNode++) {
            var latlng = new RLatLng(parseFloat(latnodes[iNode].firstChild.nodeValue),
parseFloat(lngnodes[iNode].firstChild.nodeValue)
);
            mbps[iNode] = new RMBPoint(idnodes[iNode].firstChild.nodeValue,
namenodes[iNode].firstChild.nodeValue,
typenodes[iNode].firstChild.nodeValue,
latlng);
            if (addrnodes.length > 0) {
                if (addrnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].address = addrnodes[iNode].firstChild.nodeValue;
                }
            }
            if (telnodes.length > 0) {
                if (telnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].telephone = telnodes[iNode].firstChild.nodeValue;
                }
            }
            if (zonenodes.length > 0) {
                if (zonenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].zone = zonenodes[iNode].firstChild.nodeValue;
                }
            }
            if (postalcodenodes.length > 0) {
                if (postalcodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].postalcode = postalcodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (picnodes.length > 0) {
                if (picnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].picture = picnodes[iNode].firstChild.nodeValue;
                }
            }
            if (mailnodes.length > 0) {
                if (mailnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].email = mailnodes[iNode].firstChild.nodeValue;
                }
            }
            if (urlnodes.length > 0) {
                if (urlnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].url = urlnodes[iNode].firstChild.nodeValue;
                }
            }
            if (faxnodes.length > 0) {
                if (faxnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].fax = faxnodes[iNode].firstChild.nodeValue;
                }
            }
            if (topidnodes.length > 0) {
                if (topidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].toptypeid = topidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (topnamenodes.length > 0) {
                if (topnamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].toptypename = topnamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (secondidnodes.length > 0) {
                if (secondidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].secondtypeid = secondidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (secondnamenodes.length > 0) {
                if (secondnamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].secondtypename = secondnamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (thirdidnodes.length > 0) {
                if (thirdidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].thirdtypeid = thirdidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (thirdnamenodes.length > 0) {
                if (thirdnamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].thirdtypename = thirdnamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (cantoncodenodes.length > 0) {
                if (cantoncodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].cantoncode = cantoncodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (cantonnamenodes.length > 0) {
                if (cantonnamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].cantonname = cantonnamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (parentcodenodes.length > 0) {
                if (parentcodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].parentcantoncode = parentcodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (parentnamenodes.length > 0) {
                if (parentnamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].parentcantonname = parentnamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (grandcodenodes.length > 0) {
                if (grandcodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].grandparentcantoncode = grandcodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (grandnamenodes.length > 0) {
                if (grandnamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].grandparentcantonname = grandnamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (claimnodes.length > 0) {
                if (claimnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].hasClaimed = claimnodes[iNode].firstChild.nodeValue;
                }
            }
            if (refernodes.length > 0) {
                if (refernodes[iNode].childNodes.length > 0) {
                    mbps[iNode].referString = refernodes[iNode].firstChild.nodeValue;
                }
            }
            if (promotionnodes.length > 0) {
                if (promotionnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].promotion = promotionnodes[iNode].firstChild.nodeValue;
                }
            }
            if (businessscopenodes.length > 0) {
                if (businessscopenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].businessscope = businessscopenodes[iNode].firstChild.nodeValue;
                }
            }
        }
        return mbps;
    }
    this.convertShowGpsidResponse = function(xmldoc) {
        var mbps = new Array();
        try {
            xmldoc.getElementsByTagName("abc");
        }
        catch (e) {
            return mbps;
        }
        var gpsidnodes = xmldoc.getElementsByTagName("gpsid");
        var useridnodes = xmldoc.getElementsByTagName("USER_ID");
        var namenodes = xmldoc.getElementsByTagName("NAME");
        var gpsid_titlenodes = xmldoc.getElementsByTagName("gpsid_title");
        var PointAddressnodes = xmldoc.getElementsByTagName("PointAddress");
        var gpsid_descriptionnodes = xmldoc.getElementsByTagName("gpsid_description");
        var typenodes = xmldoc.getElementsByTagName("TYPE");
        var telnodes = xmldoc.getElementsByTagName("TEL");
        var postalcodenodes = xmldoc.getElementsByTagName("POSTALCODE");
        var addressnodes = xmldoc.getElementsByTagName("ADDRESS");
        var picnodes = xmldoc.getElementsByTagName("PIC");
        var faxnodes = xmldoc.getElementsByTagName("FAX");
        var urlnodes = xmldoc.getElementsByTagName("URL");
        var emailnodes = xmldoc.getElementsByTagName("EMAIL");
        var latnodes = xmldoc.getElementsByTagName("LATITUDE");
        var lngnodes = xmldoc.getElementsByTagName("LONGITUDE");
        var infonodes = xmldoc.getElementsByTagName("INFO");
        var cantoncodenodes = xmldoc.getElementsByTagName("CANTONCODE");
        var cantonnamenodes = xmldoc.getElementsByTagName("CANTONNAME");
        var parentcodenodes = xmldoc.getElementsByTagName("PARENTCODE");
        var parentcantonnodes = xmldoc.getElementsByTagName("PARENTCANTONNAME");
        var grandparentcodenodes = xmldoc.getElementsByTagName("GRANDPARENTCODE");
        var grandparentcantonnamenodes = xmldoc.getElementsByTagName("GRANDPARENTCANTONNAME");
        var mbp_typenodes = xmldoc.getElementsByTagName("MBP_TYPE");
        var telzonenonodes = xmldoc.getElementsByTagName("TELZONENO");
        var temp_stringnodes = xmldoc.getElementsByTagName("TEMP_STRING");
        var mainbodeidnodes = xmldoc.getElementsByTagName("MAINBODYID");
        var typeidnodes = xmldoc.getElementsByTagName("TYPEID");
        var type_namenodes = xmldoc.getElementsByTagName("TYPE_NAME");
        var toptypeidnodes = xmldoc.getElementsByTagName("TOPTYPEID");
        var toptypenamenodes = xmldoc.getElementsByTagName("TOPTYPENAME");
        var secondtypeidnodes = xmldoc.getElementsByTagName("SECONDTYPEID");
        var secondtypenamenodes = xmldoc.getElementsByTagName("SECONDTYPENAME");
        var thirdtypeidnodes = xmldoc.getElementsByTagName("THIRDTYPEID");
        var thirdtypenamenodes = xmldoc.getElementsByTagName("THIRDTYPENAME");
        var pinyin_temp_stringnodes = xmldoc.getElementsByTagName("PINYIN_TEMP_STRING");
        var google_temp_stringnodes = xmldoc.getElementsByTagName("GOOGLE_INFLUENCE");
        var lastupdatetimenodes = xmldoc.getElementsByTagName("LASTUPDATETIME");
        var refernodes = xmldoc.getElementsByTagName("Refer");
        for (var iNode = 0; iNode < gpsidnodes.length; iNode++) {
            var latlng = new RLatLng(parseFloat(latnodes[iNode].firstChild.nodeValue),
parseFloat(lngnodes[iNode].firstChild.nodeValue)
);
            if (gpsid_titlenodes[iNode].childNodes.length > 0) {
                if (gpsid_titlenodes.length > 0) {
                    mbps[iNode] = new RMBPoint(useridnodes[iNode].firstChild.nodeValue,
gpsid_titlenodes[iNode].firstChild.nodeValue,
typenodes[iNode].firstChild.nodeValue,
latlng);
                }
            }
            else {
                mbps[iNode] = new RMBPoint(useridnodes[iNode].firstChild.nodeValue,
namenodes[iNode].firstChild.nodeValue,
typenodes[iNode].firstChild.nodeValue,
latlng);
            }
            if (gpsid_titlenodes.length > 0) {
                if (gpsid_titlenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].title = gpsid_titlenodes[iNode].firstChild.nodeValue;
                }
            }
            if (PointAddressnodes.length > 0) {
                if (PointAddressnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].address = PointAddressnodes[iNode].firstChild.nodeValue;
                }
            }
            if (namenodes.length > 0) {
                if (namenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].name = namenodes[iNode].firstChild.nodeValue;
                }
            }
            if (gpsid_descriptionnodes.length > 0) {
                if (gpsid_descriptionnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].description = gpsid_descriptionnodes[iNode].firstChild.nodeValue;
                }
            }
            if (picnodes.length > 0) {
                if (picnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].picture = picnodes[iNode].firstChild.nodeValue;
                }
            }
            if (postalcodenodes.length > 0) {
                if (postalcodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].postalcode = postalcodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (addressnodes.length > 0) {
                if (addressnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].address = addressnodes[iNode].firstChild.nodeValue;
                }
            }
            if (typenodes.length > 0) {
                if (typenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].type = typenodes[iNode].firstChild.nodeValue;
                }
            }
            if (telnodes.length > 0) {
                if (telnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].tel = telnodes[iNode].firstChild.nodeValue;
                }
            }
            if (faxnodes.length > 0) {
                if (faxnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].fax = faxnodes[iNode].firstChild.nodeValue;
                }
            }
            if (urlnodes.length > 0) {
                if (urlnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].url = urlnodes[iNode].firstChild.nodeValue;
                }
            }
            if (emailnodes.length > 0) {
                if (emailnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].email = emailnodes[iNode].firstChild.nodeValue;
                }
            }
            if (infonodes.length > 0) {
                if (infonodes[iNode].childNodes.length > 0) {
                    mbps[iNode].info = infonodes[iNode].firstChild.nodeValue;
                }
            }
            if (cantoncodenodes.length > 0) {
                if (cantoncodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].cantoncode = cantoncodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (parentcodenodes.length > 0) {
                if (parentcodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].parentcode = parentcodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (parentcantonnodes.length > 0) {
                if (parentcantonnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].parentcanton = parentcantonnodes[iNode].firstChild.nodeValue;
                }
            }
            if (grandparentcodenodes.length > 0) {
                if (grandparentcodenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].grandparentcode = grandparentcodenodes[iNode].firstChild.nodeValue;
                }
            }
            if (grandparentcantonnamenodes.length > 0) {
                if (grandparentcantonnamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].grandparentcantonname = grandparentcantonnamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (mbp_typenodes.length > 0) {
                if (mbp_typenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].mbp_type = mbp_typenodes[iNode].firstChild.nodeValue;
                }
            }
            if (telzonenonodes.length > 0) {
                if (telzonenonodes[iNode].childNodes.length > 0) {
                    mbps[iNode].telzone = telzonenonodes[iNode].firstChild.nodeValue;
                }
            }
            if (temp_stringnodes.length > 0) {
                if (temp_stringnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].temp_string = temp_stringnodes[iNode].firstChild.nodeValue;
                }
            }
            if (mainbodeidnodes.length > 0) {
                if (mainbodeidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].mainbodeid = mainbodeidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (typeidnodes.length > 0) {
                if (typeidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].typeid = typeidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (type_namenodes.length > 0) {
                if (type_namenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].type_name = type_namenodes[iNode].firstChild.nodeValue;
                }
            }
            if (toptypeidnodes.length > 0) {
                if (toptypeidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].toptypeid = toptypeidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (toptypenamenodes.length > 0) {
                if (toptypenamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].toptypename = toptypenamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (secondtypeidnodes.length > 0) {
                if (secondtypeidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].secondtypeid = secondtypeidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (secondtypenamenodes.length > 0) {
                if (secondtypenamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].secondtypename = secondtypenamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (thirdtypeidnodes.length > 0) {
                if (thirdtypeidnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].thirdtypeids = thirdtypeidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (thirdtypenamenodes.length > 0) {
                if (thirdtypenamenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].thirdtypename = thirdtypenamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (pinyin_temp_stringnodes.length > 0) {
                if (pinyin_temp_stringnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].pinyin_temp_string = pinyin_temp_stringnodes[iNode].firstChild.nodeValue;
                }
            }
            if (google_temp_stringnodes.length > 0) {
                if (google_temp_stringnodes[iNode].childNodes.length > 0) {
                    mbps[iNode].google_temp_string = google_temp_stringnodes[iNode].firstChild.nodeValue;
                }
            }
            if (lastupdatetimenodes.length > 0) {
                if (lastupdatetimenodes[iNode].childNodes.length > 0) {
                    mbps[iNode].lastupdatetime = lastupdatetimenodes[iNode].firstChild.nodeValue;
                }
            }
            if (refernodes.length > 0) {
                if (refernodes[iNode].childNodes.length > 0) {
                    mbps[iNode].referString = refernodes[iNode].firstChild.nodeValue;
                }
            }
        }
        return mbps;
    }
    this.convertGpsidResponse = function(xmldoc) {
        var gpsids = new Array();
        try {
            xmldoc.getElementsByTagName("GPSID");
        }
        catch (e) {
            return gpsids;
        }
        //var idnodes=xmldoc.getElementsByTagName("ID");
        var gpsidnodes = xmldoc.getElementsByTagName("GPSID");
        var titlenodes = xmldoc.getElementsByTagName("Title");
        var descnodes = xmldoc.getElementsByTagName("Description");
        var usertypenodes = xmldoc.getElementsByTagName("User_Type_Id");
        var gpsidpointnodes = xmldoc.getElementsByTagName("Gpsid_Point");
        for (var iNode = 0; iNode < gpsidnodes.length; iNode++) {
            gpsids[iNode] = new RGpsid();
            //			if(gpsidnodes.length>0){
            //				if(gpsidnodes[iNode].childNodes.length>0){
            //					gpsids[iNode].id=gpsidnodes[iNode].firstChild.nodeValue;
            //				}
            //			}
            if (gpsidnodes.length > 0) {
                if (gpsidnodes[iNode].childNodes.length > 0) {
                    gpsids[iNode].gpsid = gpsidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (titlenodes.length > 0) {
                if (titlenodes[iNode].childNodes.length > 0) {
                    gpsids[iNode].title = titlenodes[iNode].firstChild.nodeValue;
                }
            }
            if (descnodes.length > 0) {
                if (descnodes[iNode].childNodes.length > 0) {
                    gpsids[iNode].description = descnodes[iNode].firstChild.nodeValue;
                }
            }
            if (usertypenodes.length > 0) {
                if (usertypenodes[iNode].childNodes.length > 0) {
                    gpsids[iNode].type = usertypenodes[iNode].firstChild.nodeValue;
                }
            }
            if (gpsidpointnodes.length > 0) {
                if (gpsidpointnodes[iNode].childNodes.length > 0) {
                    gpsids[iNode].pointType = gpsidpointnodes[iNode].firstChild.nodeValue;
                }
            }
        }
        return gpsids;
    }
    this.convertLineResponse = function(xmldoc) {
        var lines = new Array();
        try {
            xmldoc.getElementsByTagName("abc");
        } catch (e) {
            return lines;
        }
        var idnodes = xmldoc.getElementsByTagName("LineID");
        var linenodes = xmldoc.getElementsByTagName("LineName");
        var cityidnodes = xmldoc.getElementsByTagName("CityID");
        var citynamenodes = xmldoc.getElementsByTagName("CityName");
        var startnodes = xmldoc.getElementsByTagName("StartStation");
        var endnodes = xmldoc.getElementsByTagName("EndStation");
        var directionnodes = xmldoc.getElementsByTagName("LineDirection");
        var countnodes = xmldoc.getElementsByTagName("StationCount");
        var pricenodes = xmldoc.getElementsByTagName("TicketPrice");
        var typenodes = xmldoc.getElementsByTagName("TransportType");
        for (var iNode = 0; iNode < idnodes.length; iNode++) {
            lines[iNode] = new RTransportLine();
            if (idnodes.length > 0) {
                if (idnodes[iNode].childNodes.length > 0) {
                    lines[iNode].lineId = idnodes[iNode].firstChild.nodeValue;
                }
            }
            if (linenodes.length > 0) {
                if (linenodes[iNode].childNodes.length > 0) {
                    lines[iNode].lineName = linenodes[iNode].firstChild.nodeValue;
                }
            }
            if (cityidnodes.length > 0) {
                if (cityidnodes[iNode].childNodes.length > 0) {
                    lines[iNode].cityId = cityidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (citynamenodes.length > 0) {
                if (citynamenodes[iNode].childNodes.length > 0) {
                    lines[iNode].cityName = citynamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (startnodes.length > 0) {
                if (startnodes[iNode].childNodes.length > 0) {
                    lines[iNode].startStation = startnodes[iNode].firstChild.nodeValue;
                }
            }
            if (endnodes.length > 0) {
                if (endnodes[iNode].childNodes.length > 0) {
                    lines[iNode].endStation = endnodes[iNode].firstChild.nodeValue;
                }
            }
            if (directionnodes.length > 0) {
                if (directionnodes[iNode].childNodes.length > 0) {
                    lines[iNode].lineDirection = directionnodes[iNode].firstChild.nodeValue;
                }
            }
            if (countnodes.length > 0) {
                if (countnodes[iNode].childNodes.length > 0) {
                    lines[iNode].stationCount = countnodes[iNode].firstChild.nodeValue;
                }
            }
            if (pricenodes.length > 0) {
                if (pricenodes[iNode].childNodes.length > 0) {
                    lines[iNode].ticketPrice = pricenodes[iNode].firstChild.nodeValue;
                }
            }
            if (typenodes.length > 0) {
                if (typenodes[iNode].childNodes.length > 0) {
                    lines[iNode].transportType = typenodes[iNode].firstChild.nodeValue;
                }
            }
        }
        return lines;
    }
    this.convertStationResponse = function(xmldoc) {
        var stations = new Array();
        try {
            xmldoc.getElementsByTagName("abc");
        } catch (e) {
            return stations;
        }
        var idnodes = xmldoc.getElementsByTagName("StationID");
        var namenodes = xmldoc.getElementsByTagName("StationName");
        var cityidnodes = xmldoc.getElementsByTagName("CityID");
        var citynamenodes = xmldoc.getElementsByTagName("CityName");
        var ordernodes = xmldoc.getElementsByTagName("StationOrder");
        var passlineidnodes = xmldoc.getElementsByTagName("PassLineIds");
        var passlinenamenodes = xmldoc.getElementsByTagName("PassLineNames");
        var lngnodes = xmldoc.getElementsByTagName("Longitude");
        var latnodes = xmldoc.getElementsByTagName("Latitude");
        var typenodes = xmldoc.getElementsByTagName("TransportType");
        for (var iNode = 0; iNode < idnodes.length; iNode++) {
            stations[iNode] = new RStation();
            var passlineids = '';
            var passlinenames = '';
            var lat = 0;
            var lng = 0;
            if (idnodes.length > 0) {
                if (idnodes[iNode].childNodes.length > 0) {
                    stations[iNode].stationId = idnodes[iNode].firstChild.nodeValue;
                }
            }
            if (namenodes.length > 0) {
                if (namenodes[iNode].childNodes.length > 0) {
                    stations[iNode].stationName = namenodes[iNode].firstChild.nodeValue;
                }
            }
            if (cityidnodes.length > 0) {
                if (cityidnodes[iNode].childNodes.length > 0) {
                    stations[iNode].cityId = cityidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (citynamenodes.length > 0) {
                if (citynamenodes[iNode].childNodes.length > 0) {
                    stations[iNode].cityName = citynamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (ordernodes.length > 0) {
                if (ordernodes[iNode].childNodes.length > 0) {
                    stations[iNode].stationOrder = ordernodes[iNode].firstChild.nodeValue;
                }
            }
            if (passlineidnodes.length > 0) {
                if (passlineidnodes[iNode].childNodes.length > 0) {
                    passlineids = passlineidnodes[iNode].firstChild.nodeValue;
                }
            }
            if (passlinenamenodes.length > 0) {
                if (passlinenamenodes[iNode].childNodes.length > 0) {
                    passlinenames = passlinenamenodes[iNode].firstChild.nodeValue;
                }
            }
            if (lngnodes.length > 0) {
                if (lngnodes[iNode].childNodes.length > 0) {
                    lng = lngnodes[iNode].firstChild.nodeValue;
                }
            }
            if (latnodes.length > 0) {
                if (latnodes[iNode].childNodes.length > 0) {
                    lat = latnodes[iNode].firstChild.nodeValue;
                }
            }
            if (typenodes.length > 0) {
                if (typenodes[iNode].childNodes.length > 0) {
                    stations[iNode].transportType = typenodes[iNode].firstChild.nodeValue;
                }
            }
            stations[iNode].latlng = new RLatLng(lat, lng);
            passlineids = passlineids.split(',');
            passlinenames = passlinenames.split(',');
            for (var iLine = 0; iLine < passlineids.length; iLine++) {
                stations[iNode].passLines[stations[iNode].passLines.length] = new RTransportLine(passlineids[iLine], passlinenames[iLine], null, stations[iNode].transportType, stations[iNode].cityId);
            }
        }
        return stations;
    }
}
function RXmlHttpRequest() {
    this.xmlhttp = null;
    this.clsid = null;
    this.createXmlHttp = function(clsid) {
        try {
            this.xmlhttp = new ActiveXObject(clsid);
            this.clsid = clsid;
        } catch (e) { }
    }
    this.getMSXmlHttp = function() {
        var clsids = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP.2.6', 'Microsoft.XMLHTTP.1.0', 'Microsoft.XMLHTTP.1', 'Microsoft.XMLHTTP'];
        for (var i = 0; i < clsids.length && this.xmlhttp == null; i++) {
            this.createXmlHttp(clsids[i]);
        }
    }
    if (window.ActiveXObject) {/*Microsoft IE*/
        this.getMSXmlHttp();
    } else {/*Mozilla | Netscape | Safari | Firefox*/
        this.xmlhttp = new XMLHttpRequest();
    }
    this.get = function() {
        return this.xmlhttp;
    }
    this.toString = function() {
        return 'RXmlHttpRequest';
    }
}
function RMBPoint(id, name, type, latlng) {
    this.id = id;
    this.name = name;
    this.type = parseInt(type, 10);
    this.latlng = latlng;
    this.description = '';
    this.address = '';
    this.telephone = '';
    this.postalcode = '';
    this.fax = '';
    this.picture = '';
    this.email = '';
    this.url = '';
    this.toptypeid = 0;
    this.secondtypeid = 0;
    this.thirdtypeid = 0;
    this.toptypename = '';
    this.secondtypename = '';
    this.thirdtypename = '';
    this.cantoncode = 0;
    this.parentcantoncode = 0;
    this.grandparentcantoncode = 0;
    this.cantonname = '';
    this.parentcantonname = '';
    this.grandparentcantonname = '';
    this.businessscope = '';
    this.getDescription = function() {
        var maxcount = 5;
        if (this.url) {
            maxcount = 4;
        }
        this.description = '';
        var count = 0;
        this.description += '<table><tr><td valign="top" width="230px">';
        if (this.businessscope) {
            if (this.promotion) {
                if (this.promotion != null) {
                    this.description += '<div width="100%" valign="middle" align="center" style="background-color:#ffffcc;"><table cellspacing=0 cellpadding=0 border=0><tr height=5><td></td></tr><tr><td style="font-weight:bolder;">' + this.promotion + '</td></tr><tr height=3><td></td></tr></table></div>';
                }
            }
            if (this.businessscope) {
                this.description += '经营范围：' + this.businessscope + '</br>';
            }
        }
        else {
            if (this.promotion) {
                if (this.promotion != null) {
                    this.description += '<div width="100%" valign="middle" align="center" style="background-color:#ffffcc;"><table cellspacing=0 cellpadding=0 border=0><tr height=5><td></td></tr><tr><td style="font-weight:bolder;">' + this.promotion + '</td></tr><tr height=3><td></td></tr></table></div>';
                }
            }
            if (this.toptypeid != 0) {
                this.description += '类&nbsp; 别：<a href="' + JS_SERVER + '../YellowPage/ViewTypeSec.aspx?typeid=' + this.toptypeid + '" target="_blank">' + this.toptypename + '</a>';
                if (this.secondtypeid != 0) {
                    this.description += '-<a href="' + JS_SERVER + '../YellowPage/ViewTypeDetail.aspx?typeid=' + this.secondtypeid + '" target="_blank">' + this.secondtypename + '</a>';
                    if (this.thirdtypeid != 0) {
                        this.description += '-<a href="' + JS_SERVER + '../YellowPage/ViewTypeDetail.aspx?typeid=' + this.thirdtypeid + '" target="_blank">' + this.thirdtypename + '</a>';
                    }
                }
                this.description += '<br>';
                count++;
            }
            if (this.cantonname) {
                var cantonstring = this.cantonname;
                if (this.parentcantonname) {
                    cantonstring = this.parentcantonname + '-' + cantonstring;
                    if (this.grandparentcantonname) {
                        cantonstring = this.grandparentcantonname + '-' + cantonstring;
                    }
                }
                cantonstring = '地&nbsp; 区：' + cantonstring;
                this.description += cantonstring + '<br>';
                count++;
            }
            if (this.address) {
                if (this.address != '') {
                    this.description += '地&nbsp; 址：' + this.address + '<br/>';
                }
                count++;
            }
            if (this.telephone) {
                if (this.telephone != '') {
                    this.description += '电&nbsp; 话：' + this.telephone + '<br/>';
                }
                count++;
            }
            if (this.postalcode) {
                if (this.postalcode != '') {
                    this.description += '邮&nbsp; 编：' + this.postalcode + '<br/>';
                }
                count++;
            }
            if (this.email && count < maxcount) {
                this.description += '邮&nbsp; 箱：' + this.email + '<br/>';
                count++;
            }
            if (this.fax && count < maxcount) {
                this.description += '传&nbsp; 真：' + this.fax + '<br/>';
                count++;
            }
            if (this.url) {
                if (this.url.indexOf('http://') == -1) {
                    this.url = 'http://' + this.url;
                }
                this.description += '网&nbsp; 址：<a href="' + this.url + '">' + this.url.substring(0, 30) + '...</a><br/>';
                count++;
            }
        }
        if (this.picture) {
            if (this.picture == "" || this.picture == "zwsc.jpg")
            { }
            else {
                this.description += '<td valign="top"  width="50px" height="50px"><a target="_blank" href="../ADB/' + this.picture + '"><img style="border:0px;width:50px;height:50px;"  src="../ADB/' + this.picture + '" /></a></td>'
            }
        }
        this.description += '</td></tr></table>';
        return this.description;
    }
    this.getDescriptionWithLink = function() {
        if (this.type == "2") {
            this.description = this.getDescription();
            this.descriptionWithLink = this.description + '<a href="' + JS_SERVER + '../POIInfo/show_mb.aspx?ID=' + this.id + '&TYPE=' + this.type + '" target=_blank>详情</a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick=\'SetAsStart("' + this.name + '","' + this.latlng.lat + '","' + this.latlng.lng + '")\'>从这里出发</a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick=\'SetAsEnd("' + this.name + '","' + this.latlng.lat + '","' + this.latlng.lng + '")\'>到这里去</a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick=\'SetSearchRoundBox("' + this.latlng.lat + '","' + this.latlng.lng + '")\'>周边</a>&nbsp;&nbsp;' + ((this.hasClaimed != '0') ? '' : '<a href="' + JS_SERVER + '../Company/CompanyClaim.aspx?EnterpriseID=' + this.id + '" target="_blank">认领</a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick=\'Magnify("' + this.latlng.lat + '","' + this.latlng.lng + '")\'>放大</a>');
        }
        else {
            this.descriptionWithLink = "";
        }
        return this.descriptionWithLink;
    }
    this.toString = function() {
        return 'RMBPoint';
    }
    this.getURL = function() {
        return JS_SERVER + '../POIInfo/show_mb.aspx?ID=' + this.id + '&TYPE=' + this.type;
    }
    this.getRituCode = function() {
        return rituEncoding(this.latlng.lat, this.latlng.lng);
    }
}
// JScript 文件
function RGpsid(id, gpsid, title, description, type, pointType) {
    this.toString = function() {
        return 'RGpsid';
    }
    if (id) {
        this.id = id;
    } else {
        this.id = -1;
    }
    if (gpsid) {
        this.gpsid = gpsid;
    } else {
        this.gpsid = '';
    }
    if (title) {
        this.title = title;
    } else {
        this.title = '';
    }
    if (description) {
        this.description = description;
    } else {
        this.description = '';
    }
    if (type) {
        this.type = type;
    } else {
        this.type = 1;
    }
    if (pointType) {
        this.pointType = 0;
    }
    this.getTypeDescription = function() {
        switch (this.type) {
            case 0:
            case '0':
                return '未知';
                break;
            case 1:
            case '1':
                return '单一';
                break;
            case 2:
            case '2':
                return '连锁';
                break;
            default:
                return '未知';
                break;
        }
        return '未知';
    }
    this.getType = function() {
        switch (this.type) {
            case 1:
            case '1':
                return '个人';
                break;
            case 2:
            case '2':
                return '企业';
                break;
            default:
                return '未知';
                break;
        }
        return '未知';
    }
    this.getPointTypeDescription = function() {
        switch (this.pointType) {
            case 0:
            case '0':
                return '不指向';
                break;
            case 1:
            case '1':
                return '已认领企业';
                break;
            case 2:
            case '2':
                return '其它企业';
                break;
            case 3:
            case '3':
                return '已认领企业地址';
                break;
            case 4:
            case '4':
                return '其它企业';
                break;
            default:
                return '无指向';
                break;
        }
        return '无指向';
    }
    this.isNonEmptyPointer = function() {
        return this.pointType != 0 && this.pointType != '0';
    }
}
// JScript 文件
//Creator:JackyLee;Time:16:40 2007-7-19
function RTransportLine(lineId, lineName, lineDirection, transportType, cityId) {
    this.toString = function() {
        return 'RTransportLine';
    }
    if (lineId) {
        this.lineId = lineId;
    } else {
        this.lineId = -1;
    }
    if (lineName) {
        this.lineName = lineName;
    } else {
        this.lineName = '';
    }
    if (lineDirection) {
        this.lineDirection = lineDirection;
    } else {
        this.lineDirection = '';
    }
    if (transportType) {
        this.transportType = transportType;
    } else {
        this.transportType = 0;
    }
    if (cityId) {
        this.cityId = cityId;
    } else {
        this.cityId = -1;
    }
    this.startStation = '';
    this.endStation = '';
    this.stationCount = 0;
    this.ticketPrice = 0;
    this.cityName = '';
    this.getTransportType = function() {
        switch (this.transportType) {
            case 1:
            case '1':
                return '公交';
                break;
            case 2:
            case '2':
                return '地铁';
                break;
            case 3:
            case '3':
                return '长途汽车';
                break;
            case 4:
            case '4':
                return '火车';
                break;
            case 5:
            case '5':
                return '飞机';
                break;
            case 6:
            case '6':
                return '轮船';
                break;
            default:
                return '未知';
                break;
        }
    }
    this.getLineDirection = function() {
        switch (this.lineDirection) {
            case 1:
            case '1':
                return '上行';
                break;
            case 2:
            case '2':
                return '下行';
                break;
            case 3:
            case '3':
                return '环线';
                break;
            default:
                return '未知';
                break;
        }
    }
    this.getLineDetailUrl = function() {
        switch (this.transportType) {
            case 1:
            case '1':
                return '/POIInfo/BusLineInfo.aspx?lid=' + this.lineId + '&cid=' + this.cityId;
                break;
            case 2:
            case '2':
                return '/POIInfo/SubwayLineInfo.aspx?lid=' + this.lineId + '&cid=' + this.cityId;
                break;
            case 3:
            case '3':
                return '#';
                break;
            case 4:
            case '4':
                return '#';
                break;
            case 5:
            case '5':
                return '#';
                break;
            case 6:
            case '6':
                return '#';
                break;
            default:
                return '#';
                break;
        }
    }
}
// JScript 文件
//Creator:JackyLee,Time:13:30 2007-7-20
function RStation(stationId, stationName, latlng, transportType, cityId) {
    this.toString = function() {
        return 'RStation';
    }
    if (stationId) {
        this.stationId = stationId;
    } else {
        this.stationId = -1;
    }
    if (stationName) {
        this.stationName = stationName;
    } else {
        this.stationName = '';
    }
    if (latlng) {
        this.latlng = latlng;
    } else {
        this.latlng = null;
    }
    if (transportType) {
        this.transportType = transportType;
    } else {
        this.transportType = 1;
    }
    if (cityId) {
        this.cityId = cityId;
    } else {
        this.cityId = -1;
    }
    this.cityName = '';
    this.passLines = new Array();
    this.getPassLineDescription = function() {
        var lineDescription = '';
        for (var iLine = 0; iLine < this.passLines.length; iLine++) {
            lineDescription += '<a href="' + this.passLines[iLine].getLineDetailUrl() + '" target="_blank">' + this.passLines[iLine].lineName + '</a>' + ', '
        }
        lineDescription = lineDescription.substring(0, lineDescription.length - 1);
        return lineDescription;
    }
    this.getTransportType = function() {
        switch (this.transportType) {
            case 1:
            case '1':
                return '公交';
                break;
            case 2:
            case '2':
                return '地铁';
                break;
            case 3:
            case '3':
                return '长途汽车';
                break;
            case 4:
            case '4':
                return '火车';
                break;
            case 5:
            case '5':
                return '飞机';
                break;
            case 6:
            case '6':
                return '轮船';
                break;
            default:
                return '未知';
                break;
        }
    }
    this.getDescriptionWithLink = function() {
        return '类型：' + this.getTransportType() + '<br>'
+ '城市：' + this.cityName + '<br>'
+ '瑞图号：' + rituEncoding(this.latlng.lat, this.latlng.lng) + '<br>'
+ '所经线路：' + this.getPassLineDescription();
    }
}
function RRectZoominTool(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.maplet = null;
    this.marker = null;
    this.leftbottom = null;
    this.righttop = null;
    this.bounds = null;
    this.isLock = true;
    this.isUseing = false;
    this.isKeepOtherMarker = false;
    if (tool.src) {
        this.imgpath = this.tool.src;
    }
    this.toString = function() {
        return 'RRectZoominTool';
    }
    this.turnon = function() {
        //创建监听
        this.addEvt();
        if (this.isLock) {
            return;
        }
        this.notify('onturnon');
        this.maplistener = new Object();
        this.maplistener.root = this;
        this.maplet.setCursor('crosshair');
        this.maplistener.onmousedown = function() {
            this.root.notify('onbegin');
            this.root.maplet.setCursor('crosshair');
            this.root.isUseing = true;
            this.root.maplet.disableDrag();
            var left = this.root.maplet.mouseX - getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode)).left;
            var top = this.root.maplet.mouseY - getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode)).top;
            this.root.leftbottom = this.root.maplet.getLatLng(left, top);
            this.root.marker = this.root.maplet.addStaticRectRegionMarker(new RBounds(this.root.leftbottom, this.root.leftbottom));
        }
        this.maplistener.onmousemoved = function() {
            if (this.root.isUseing) {
                this.root.maplet.setCursor('crosshair');
                var left = this.root.maplet.mouseX - getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode)).left;
                var top = this.root.maplet.mouseY - getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode)).top;
                this.root.marker.righttop = this.root.maplet.getLatLng(left, top);
                this.root.maplet.refreshMarkers();
            }
        }
        this.maplistener.onmouseup = function() {
            var left = this.root.maplet.mouseX - getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode)).left;
            var top = this.root.maplet.mouseY - getBoundingClientRect((this.root.maplet.get().parentElement || this.root.maplet.get().parentNode)).top;
            this.root.righttop = this.root.maplet.getLatLng(left, top);
            this.root.marker.destroy();
            this.root.maplet.setCursor('crosshair');
            this.root.maplet.enableDrag();
            this.root.isUseing = false;
            this.root.notify('onsuccess');
            if (this.root.leftbottom.lat != this.root.righttop.lat || this.root.leftbottom.lng != this.root.righttop.lng) {//alert(this.root.maplet.zoomlevels);
                if (this.root.maplet.zoom == this.root.maplet.availableMaxZoomLevel) {
                    this.root.maplet.isReturnboundsCenter = true; //
                    this.root.maplet.getMaxLatLngFromArray(new Array(this.root.leftbottom, this.root.righttop), false);
                    this.root.maplet.isReturnboundsCenter = false; //
                    this.root.maplet.smoothMove(this.root.maplet.boundsCenter.lat, this.root.maplet.boundsCenter.lng);
                }
                else {
                    this.root.maplet.dynSetMaxBoundsByLatLngs(new Array(this.root.leftbottom, this.root.righttop), false, -70);
                }
            }
        }
        this.maplet.addListener(this.maplistener, 'onmousedown');
        this.maplet.addListener(this.maplistener, 'onmousemoved');
        this.maplet.addListener(this.maplistener, 'onmouseup');
    }
    this.turnoff = function() {
        this.isLock = true;
        this.maplet.setCursor('default');
        this.notify('onturnoff');
        if (this.maplistener) {
            this.maplistener.onmousedown = function() { };
            this.maplistener.onmousemoved = function() { };
            this.maplistener.onmouseup = function() { };
        }
        if (this.imgpath) {
            this.tool.src = this.imgpath;
        }
    }
    this.clear = function() { };
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
    }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.keydown = function(evt) {
        if ((evt || window.event).keyCode == 27) {
            this.turnoff();
            this.delEvt();
            if (this.marker) {
                this.marker.destroy();
            }
            this.maplet.enableDrag();
        }
    }
    //创建一个Esc建的监听事件
    this.addEvt = function() {
        if (window.event) //IE
        {
            g_addListener("keydown", this.keydown, this);
            document.attachEvent("onkeydown", g_notify);
        }
        else  //Firefox
        {
            g_addListener("keydown", this.keydown, this);
            document.addEventListener("keydown", g_notify, false);
        }
    }
    //销毁ESC键的监听事件
    this.delEvt = function() {
        if (document.attachEvent) {
            document.detachEvent("onkeydown", g_notify);
        }
        else {
            document.removeEventListener("keydown", g_notify, false);
        }
    }
}
g_dropList_p = new Array();
function RLocationDropList(nCityId, nWidth, size, objTextField, strDefaultText) {
    this.textfield = null;
    this.cityid = 0;
    this.defaultText = "";
    this.listWidth = 150;
    this.oldValue = "";
    this.maxCount = 10;
    this.selectedIndex = -1;
    this.selectedValue = null;
    this.selectedText = "";
    this.fadeColor = '#cccccc';
    this.normalColor = '#000000';
    this.isCancelled = false;
    this.hasValue = false;
    if (objTextField) {
        this.textfield = objTextField;
    } else {
        return null;
    }
    if (nWidth) {
        this.listWidth = nWidth;
    } else {
        this.listWidth = 150;
    }
    if (nCityId) {
        this.cityid = nCityId;
    } else {
        this.cityid = 0;
    }
    if (strDefaultText) {
        this.defaultText = strDefaultText;
        this.oldValue = strDefaultText;
        this.textfield.value = this.defaultText;
        this.textfield.style.color = this.fadeColor;
    } else {
        this.defaultText = "";
        this.oldValue = "";
    }
    this.setLeftTop = function(left, top) {
        this.list.get().style.left = left;
        this.list.get().style.top = top;
    }
    var bounds = getBoundingClientRect(this.textfield);
    this.list = new RList(bounds.left, bounds.bottom, this.listWidth, size * 20);
    this.list.style.border = '1px solid #000000';
    this.list.style.zIndex = 10001;
    this.list.style.visibility = 'hidden';
    document.body.appendChild(this.list.get());
    this.setList = function(aryInfo) {
        this.hasValue = true;
        if (this.isCancelled) {
            this.isCancelled = false;
            return;
        }
        if (!aryInfo.ResultInfo) {
            this.list.show();
            this.list.clear();
            this.list.addListItem('服务器出错', null, null);
            setRTimeout(this.list, this.list.hide, 1000);
        } else if (aryInfo.ResultInfo[0].TotalCount[0].nodeValue == "0") {
            this.list.show();
            this.list.clear();
            this.list.addListItem('没有找到与<b><span style="color:red;">“' + this.textfield.value + '”</span></b>相关的信息', null, null);
            setRTimeout(this.list, this.list.hide, 2000);
        } else {
            this.list.clear();
            for (var iLoop = 0; iLoop < aryInfo.Point.length; iLoop++) {
                this.list.addListItem(aryInfo.Point[iLoop].PointName[0].nodeValue, aryInfo.Point[iLoop], aryInfo.Point[iLoop].PointAddress[0].nodeValue);
            }
            //			this.list.show();
            this.isShowing = true;
            window.status = '完成';
        }
    }
    this.setCity = function(nCityId) {
        if (nCityId) {
            this.cityid = nCityId;
        } else {
            this.cityid = 0;
        }
    }
    this.toString = function() {
        return "RLocationDropList";
    }
    this.setDefaultText = function(strDefaultText) {
        this.defaultText = strDefaultText;
        this.textfield.value = strDefaultText;
        this.oldValue = strDefaultText;
    }
    this.keyCount = 0;
    this.textfield.root = this;
    this.textfield.onblur = function(evt) { //失去焦点
        if (this.root.oldValue != this.value) {
            this.root.notify('ontextchanged');
        }
        if (this.root.defaultText && this.root.defaultText != '') {
            if (trim(this.value) == '') {
                this.value = this.root.defaultText;
                this.style.color = this.root.fadeColor;
            }
        }
        if (this.root.hasValue) {
            this.root.leave(evt);
        }
        this.root.notify('onleave');
    }
    this.leave = function(evt) {
        this.cancel();
        if (!this.isShowing) { return; }
        if (this.list.isMouseOver) {
            return;
        } else {
            this.list.hide();
        }
    }
    this.textfield.onkeyup = function(evt) {
        this.style.color = this.root.normalColor;
        this.root.keyCount++;
        this.root.isCancelled = false;
        setRTimeout(this.root, this.root.isKeyStopped, 1500, [this.root.keyCount]);
        if (this.value != this.root.oldValue) {
            this.root.oldValue = this.value;
            this.root.notify('ontextchanged');
            this.root.isTextChanged = true;
        } else {
            this.root.isTextChanged = false;
        }
        this.recentupkey = (window.event || evt).keyCode;
        this.root.notify('onkeyup');
    }
    this.isKeyStopped = function(keyCount) {
        if (this.keyCount == keyCount) {
            this.keyCount = 0;
            this.notify('onkeystopped');
        }
    }
    this.textfield.onfocus = function() {
        if (this.value == this.root.defaultText) {
            this.value = '';
        }
        this.style.color = this.normalColor;
        this.root.notify('onactivation');
    }
    this.textfield.onkeydown = function(evt) {
        this.recentkey = (window.event || evt).keyCode;
        if (this.recentkey == 38) {
            this.root.list.highlightprev();
        } else if (this.recentkey == 40) {
            this.root.list.highlightnext();
        } else if (this.recentkey == 13) {
            this.root.list.check(this.root.list.highlightIndex);
        }
    }
    this.onselected = new Array();
    this.onkeystopped = new Array();
    this.ontextchanged = new Array();
    this.onleave = new Array();
    this.onkeyup = new Array();
    this.onactivation = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onselected':
                if (listener.onselected) {
                    this.onselected[this.onselected.length] = listener;
                }
                break;
            case 'onkeystopped':
                if (listener.onkeystopped) {
                    this.onkeystopped[this.onkeystopped.length] = listener;
                }
                break;
            case 'ontextchanged':
                if (listener.ontextchanged) {
                    this.ontextchanged[this.ontextchanged.length] = listener;
                }
                break;
            case 'onleave':
                if (listener.onleave) {
                    this.onleave[this.onleave.length] = listener;
                }
                break;
            case 'onkeyup':
                if (listener.onkeyup) {
                    this.onkeyup[this.onkeyup.length] = listener;
                }
                break;
            case 'onactivation':
                if (listener.onactivation) {
                    this.onactivation[this.onactivation.length] = listener;
                }
                break;
            default:
                window.status = this.toString() + '不存在事件：' + estring;
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onselected':
                for (var i = 0; i < this.onselected.length; i++) {
                    if (this.onselected[i].onselected) {
                        this.onselected[i].onselected();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onkeystopped':
                for (var i = 0; i < this.onkeystopped.length; i++) {
                    if (this.onkeystopped[i].onkeystopped) {
                        this.onkeystopped[i].onkeystopped();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'ontextchanged':
                for (var i = 0; i < this.ontextchanged.length; i++) {
                    if (this.ontextchanged[i].ontextchanged) {
                        this.ontextchanged[i].ontextchanged();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onleave':
                for (var i = 0; i < this.onleave.length; i++) {
                    if (this.onleave[i].onleave) {
                        this.onleave[i].onleave();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onkeyup':
                for (var i = 0; i < this.onkeyup.length; i++) {
                    if (this.onkeyup[i].onkeyup) {
                        this.onkeyup[i].onkeyup();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            case 'onactivation':
                for (var i = 0; i < this.onactivation.length; i++) {
                    if (this.onactivation[i].onactivation) {
                        this.onactivation[i].onactivation();
                    } else {
                        window.status = '事件监听对象的事件处理方法调用失败：' + this.toString() + ',' + estring;
                    }
                }
                break;
            default:
                window.status = this.toString() + '抛出了一个未经定义的事件：' + estring;
                break;
        }
    }
    this.onclicked = function() {
        if (this.list.selectedText != '正在查询，请稍候') {//alert();
            this.selectedIndex = this.list.selectedIndex;
            this.selectedValue = this.list.selectedValue;
            this.selectedText = this.list.selectedText;
            this.list.clear()
            this.list.hide();
            this.isShowing = false;
            this.isSelected = true;
            this.textfield.value = this.selectedText;
            this.notify('onselected');
        }
    }
    this.list.addListener(this, 'onclicked');
    this.hide = function() {
        this.list.hide();
    }
    this.cancel = function() {
        this.isCancelled = true;
    }
    this.pageDiv = new RDiv(0, 0, 0, 0).get();
    this.pageDiv.style.display = "none";
    this.pageIframe = null;
    document.body.appendChild(this.pageDiv);
    this.aryPoint = g_dropList_p.length;
    g_dropList_p[g_dropList_p.length] = this;
    this.getDataPage = function() {
        this.pageIframe = null;
        this.pageIframe = document.createElement("iframe");
        this.pageDiv.appendChild(this.pageIframe);
        this.pageIframe.src = '/getdatas/getDropListData.aspx?kw=' + escape(trim(this.textfield.value)) + '&cid=' + parent.CityId + '&count=' + this.maxCount + '&arypoint=' + this.aryPoint;
        this.list.show();
        this.list.clear();
        this.list.isChecking = false;
        this.list.addListItem('正在查询，请稍候', null, null);
    }
    this.droplistlistener = new Object();
    this.droplistlistener.root = this;
    this.droplistlistener.onkeystopped = function() {
        if (this.root.textfield.value == this.root.defaultText) {
            this.root.textfield.style.color = this.root.fadeColor;
            return;
        } else if (trim(this.root.textfield.value) == "") {
            return;
        } else {
            if (!this.root.isTextChanged || this.root.isSelected) {
                this.root.isSelected = false;
                this.root.isTextChanged = true;
            } else {
                var bounds = firefoxGetBoundingClientRect(this.root.textfield);
                this.root.list.style.left = bounds.left;
                this.root.list.style.top = bounds.bottom - 2;
                var kw = trim(this.root.textfield.value);
                if (this.root.isCancelled) {
                    this.root.isCancelled = false;
                    return;
                } else {
                    this.root.getDataPage();
                }
            }
        }
    }
    this.addListener(this.droplistlistener, 'onkeystopped');
}
function RFavorite(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.maplet = null;
    this.userCookies = new Array();
    this.userAnnal = new Array();
    this.itemName = '请为当前地图添加名称，然后收藏';
    this.isLock = true;
    this.isUseing = false;
    this.isKeepOtherMarker = true;
    this.div = new RDiv(0, 0, null, null).get();
    this.div.id = "RFavorite";
    this.div.style.display = "none";
    this.div.style.visibility = "hidden";
    document.body.appendChild(this.div);
    this.innerdiv = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdiv);
    this.style = this.div.style;
    if (!this.closebtn) {
        this.closebtn = new RImage(this.width - 30, 13, '/img/favoriteClose.gif').get();
    }
    this.closebtn.style.cursor = 'pointer';
    this.closebtn.style.left = '235px';
    this.closebtn.style.top = '8px';
    this.closebtn.root = this;
    this.div.appendChild(this.closebtn);
    this.closebtn.onclick = function() {
        this.root.turnoff();
    }
    this.setInnerHTML = function() {
        this.innerHTMLChild = '';
        this.strCookies = getCookie("RFavorite");
        if (this.strCookies) {
            this.userCookies = this.strCookies.split(";");
        } else {
            this.userCookies = "";
        }
        this.userAnnal = this.userCookies;
        for (var i = 0; i < this.userCookies.length; i++) {
            this.userAnnal[i] = this.userCookies[i].split(",");
            this.innerHTMLChild += '<table style="width:90%; height:30px; border-bottom:1px dashed #666666; font-size:12px;">'
+ '<tr><td style="text-align:left;"><input id="checkbox' + i + '" type="checkbox" name="checkbox" value="checkbox" /><a href="#" id="favoriteChooseOne' + i + '" onmousedown="this.chooseOne(' + this.userAnnal[i][1] + ',' + this.userAnnal[i][2] + ',' + this.userAnnal[i][3] + ')">' + this.userAnnal[i][0] + '</a></td><td style="text-align:right; width:60px;">' + this.userAnnal[i][4] + '</td></tr>'
+ '</table>';
        }
        var divInnerHTML = '<table style="width:260px; border:1px solid #44A7D1; background-color:#FFFFFF;">'
+ '<tr><td style="width:100%; height:30px; background-image:url(/img/FavoriteTitlebg.gif);"><table>'
+ '<tr><td style="width:5px;"></td><td  style="color: #ffffff;font-size: 14px; font-weight:bold;">您所收藏的地图</td></tr>'
+ '</table></td></tr>'
+ '<tr><td id="FavoriteBoxHead" style="width:100%;"><table>'
+ '<tr><td style=""><input id="itemName" name="textfield"  type="text" size="28" style="color:#CCCCCC;"  value="' + this.itemName + '" maxlength="15" onkeyup="isValidate(this);"/></td><td><strong><a id="favoriteAddItem" href="#" style="font-size:12px">收藏</a></strong></td></tr>'
+ '</table></td></tr>'
+ '<tr><td style="text-align:center;">'
+ this.innerHTMLChild
+ '</td></tr><tr><td style="height:10px;"></td></tr>';
        if (this.innerHTMLChild != "") {
            divInnerHTML += '<tr><td style=""><table style="width:100%;">'
+ '<tr><td style="text-align:left;">&nbsp;&nbsp;<input id="favoriteSelectAll" type="submit" name="selectAll" value="全选" />&nbsp;&nbsp;<input id="favoriteDeleteChoose" type="submit" name="deleteChoose" value="删除选中" /></td></tr>'
+ '</table></td></tr>';
        }
        divInnerHTML += '</table>';
        this.innerdiv.innerHTML = divInnerHTML;
        if (document.getElementById('itemName')) {
            document.getElementById('itemName').root = this;
            document.getElementById('itemName').onfocus = function() {
                this.style.color = "#000000";
                if (trim(this.value) == this.root.itemName) {
                    this.value = "";
                }
            }
            document.getElementById('itemName').onblur = function() {
                if (trim(this.value) == "") {
                    this.style.color = "#CCCCCC";
                    this.value = this.root.itemName;
                }
            }
        }
    }
    this.setObjOnclick = function() {
        if (document.getElementById('favoriteAddItem')) {
            document.getElementById('favoriteAddItem').root = this;
            document.getElementById('favoriteAddItem').onclick = function() {
                var temStr = '';
                if (this.root.userAnnal.length < 6) {
                    var words = trim(document.getElementById('itemName').value.replace(this.root.itemName, ''));
                    if (words && words != '') {
                        if (words.length > 12) {
                            words = words.substring(0, 12) + '...';
                        }
                        temStr += words;
                        var now = new Date();
                        var timeStr = now.getYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
                        var mapCenter = this.root.maplet.getCenter();
                        temStr += ',' + mapCenter.lat + ',' + mapCenter.lng + ',' + this.root.maplet.getZoomLevel() + ',' + timeStr;
                        for (var i = 0; i < this.root.userAnnal.length; i++) {
                            temStr += ';' + this.root.userAnnal[i][0] + ',' + this.root.userAnnal[i][1] + ',' + this.root.userAnnal[i][2] + ',' + this.root.userAnnal[i][3] + ',' + this.root.userAnnal[i][4];
                        }
                        setCookie("RFavorite", temStr, 365);
                    } else {
                        alert("请先输入名称");
                    }
                } else {
                    alert("最多能收藏6条");
                    return;
                }
                this.root.setInnerHTML();
                this.root.setObjOnclick();
            }
        }
        if (document.getElementById('favoriteSelectAll')) {
            document.getElementById('favoriteSelectAll').onclick = function() {
                var i = 0;
                var isAllCheck = true;
                while (document.getElementById('checkbox' + i)) {
                    if (document.getElementById('checkbox' + i).checked == false) {
                        isAllCheck = false;
                        break;
                    }
                    i++;
                }
                i = 0;
                if (isAllCheck == false) {
                    while (document.getElementById('checkbox' + i)) {
                        document.getElementById('checkbox' + i).checked = true;
                        i++;
                    }
                } else {
                    while (document.getElementById('checkbox' + i)) {
                        document.getElementById('checkbox' + i).checked = false;
                        i++;
                    }
                }
            }
        }
        if (document.getElementById('favoriteDeleteChoose')) {
            document.getElementById('favoriteDeleteChoose').root = this;
            document.getElementById('favoriteDeleteChoose').onclick = function() {
                //                if(confirm('是否确定删除？')){
                var i = 0;
                var selectItem = new Array();
                while (document.getElementById('checkbox' + i)) {
                    if (document.getElementById('checkbox' + i).checked == true) {
                        selectItem[selectItem.length] = i;
                    }
                    i++;
                }
                if (i <= 0) {
                    alert("你还没添加收藏，没有项可删除");
                    return;
                }
                if (selectItem.length <= 0) {
                    alert("请先选择要删除的项");
                    return;
                }
                var temStr = '';
                var jIndex = 0;
                var isDeleteItem = false; //是否为被删除项
                for (var j = 0; j < this.root.userAnnal.length; j++) {
                    for (var k = 0; k < selectItem.length; k++) {
                        if (j == selectItem[k]) {//在删除项数组中找到
                            isDeleteItem = true; //设为删除项
                            break;
                        }
                    }
                    if (isDeleteItem == false) {
                        if (jIndex != 0) {
                            temStr += ';'
                        }
                        temStr += this.root.userAnnal[j][0] + ',' + this.root.userAnnal[j][1] + ',' + this.root.userAnnal[j][2] + ',' + this.root.userAnnal[j][3] + ',' + this.root.userAnnal[j][4];
                        jIndex++;
                    } else {
                        isDeleteItem = false;
                    }
                }
                setCookie("RFavorite", temStr, 365);
                this.root.setInnerHTML();
                this.root.setObjOnclick();
            }
            //	        }
        }
        for (var i = 0; i < this.userAnnal.length; i++) {
            if (document.getElementById('favoriteChooseOne' + i)) {
                document.getElementById('favoriteChooseOne' + i).root = this;
                document.getElementById('favoriteChooseOne' + i).chooseOne = function(lat, lng, zoom) {
                    this.root.maplet.dynSmoothMove(lat, lng, zoom);
                    this.root.turnoff();
                    //                    this.root.setInnerHTML();
                    //                    this.root.setObjOnclick();
                }
            }
        }
    }
    this.get = function() { }
    if (tool.src) {
        this.imgpath = this.tool.src;
    }
    this.toString = function() {
        return 'RFavorite';
    }
    this.turnon = function() {
        if (this.isLock) {
            return;
        }
        this.isLock = false;
        this.setInnerHTML();
        this.setObjOnclick();
        this.div.style.display = "block";
        this.div.style.visibility = 'visible';
        this.div.style.left = getBoundingClientRect(this.tool).left - 60;
        this.div.style.top = getBoundingClientRect(this.tool).top + 25;
        this.userCookies = new Array();
        this.userAnnal = new Array();
        var strCookies = getCookie("RFavorite");
        if (strCookies) {
            this.userCookies = strCookies.split(";");
        }
        this.userAnnal = this.userCookies;
        for (var i = 0; i < this.userCookies.length; i++) {
            this.userAnnal[i] = this.userCookies[i].split(",");
        }
        this.notify('onturnon');
    }
    this.turnoff = function() {
        $("MapmoveTool").className = "unite_MapmoveToolOn";
        $("Favorite").className = "unite_Favorite";
        this.isLock = true;
        this.div.style.display = "none";
        this.div.style.visibility = 'hidden';
        this.notify('onturnoff');
        if (this.imgpath) {
            this.tool.src = this.imgpath;
        }
    }
    this.clear = function() { };
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
    }
    //	this.isAdjust=true;
    //	this.refreshLetTop=function(){
    //	    if(this.contextmenu&&this.isAdjust){
    //	        this.contextmenu.setLeftTop(getBoundingClientRect(this.tool).left,getBoundingClientRect(this.tool).top+18);
    //	    }
    //	    this.isAdjust=true;
    //	}
    this.mClick = function(evt) {
        if (this.div.style.display != "none") {
            var element = null;
            if (window.event) {
                element = window.event.srcElement;
            } else {
                element = evt.originalTarget;
            }
            while (element.tagName != 'BODY') {
                if (element.id == 'RFavorite' || element.id == this.tool.id) {
                    return;
                }
                element = element.parentElement || element.parentNode;
            }
            this.turnoff();
        }
    }
    if (window.event) {
        g_addListener("click", this.mClick, this);
        document.attachEvent("onclick", g_notify);
    } else {
        g_addListener("click", this.mClick, this);
        document.addEventListener("click", g_notify, false);
    }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function REmail(tool) {
    if (!tool) { return; }
    this.tool = tool;
    this.isLock = true;
    this.maplet = null;
    this.eReceiver = "收件人邮箱";
    this.eTitle = "请填写邮件的标题";
    this.eContent = "请填写邮件的内容，本站将会把内容与当前地图的网址一并发送到收件人邮箱";
    this.div = new RDiv(0, 0, null, null).get();
    this.div.id = "REmail";
    this.div.style.display = "none";
    this.div.style.visibility = "hidden";
    document.body.appendChild(this.div);
    this.innerdiv = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdiv);
    this.style = this.div.style;
    if (!this.closebtn) {
        this.closebtn = new RImage(this.width - 30, 13, '/img/favoriteClose.gif').get();
    }
    this.closebtn.style.cursor = 'pointer';
    this.closebtn.style.left = '470px';
    this.closebtn.style.top = '8px';
    this.closebtn.root = this;
    this.div.appendChild(this.closebtn);
    this.closebtn.onclick = function() {
        this.root.turnoff();
        this.root.innerdiv.innerHTML = '';
        //        this.root.setInnerHTML();
    }
    this.setInnerHTML = function() {
        this.innerdiv.innerHTML = '<table style="width:500px; background-color:#FFFFFF; border:1px solid #44A7D1;">'
+ '<tr><td colspan="3" style="width:100%; height:30px; background-image:url(/img/FavoriteTitlebg.gif);"><table>'
+ '<tr><td style="width:5px;"></td><td  style="color: #ffffff;font-size: 14px; font-weight:bold;">发送邮件</td></tr>'
+ '</table></td></tr>'
+ '<tr><td style="width:10px;"></td><td>收件人：</td><td><input id="emailReceiver" name="" type="text" size="50" style="color:#CCCCCC;" value="收件人邮箱" maxlength="30"/></td></tr>'
+ '<tr><td style="width:10px;"></td><td>标　题：</td><td><input id="emailTitle" name="" type="text" size="50" style="color:#CCCCCC;" value="请填写邮件的标题" maxlength="30"/></td></tr>'
+ '<tr><td style="width:10px;"></td><td style="vertical-align:top;">内　容：</td><td><textarea id="emailContent" name="" cols="45" rows="8" style="color:#CCCCCC;" ></textarea></td></tr>'
+ '<tr><td style="width:10px;"></td><td></td><td><input id="sEmail" type="button" name="" value="发 送" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'
+ '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="exitEmail" type="button" name="" value="取 消" /></td></tr>'
+ '<tr><td colspan="3" style="height:10px"><iframe id="emailIframe" style="display:none;" src="sandEmail.aspx"></iframe></td></tr>'
+ '</table>';
        document.frames['emailIframe'].location.reload(); //刷新iframe
        if (document.getElementById('sEmail')) {
            document.getElementById('sEmail').root = this;
            document.getElementById('sEmail').onclick = function() {
                this.root.sendEmail();
            }
        }
        if (document.getElementById('exitEmail')) {
            document.getElementById('exitEmail').root = this;
            document.getElementById('exitEmail').onclick = function() {
                this.root.turnoff();
                //                this.root.setInnerHTML();
                this.root.innerdiv.innerHTML = '';
            }
        }
        if (document.getElementById('emailReceiver')) {
            document.getElementById('emailReceiver').root = this;
            document.getElementById('emailReceiver').onfocus = function() {
                this.style.color = "#000000";
                if (trim(this.value) == this.root.eReceiver) {
                    this.value = "";
                }
            }
            document.getElementById('emailReceiver').onblur = function() {
                if (trim(this.value) == "") {
                    this.style.color = "#CCCCCC";
                    this.value = this.root.eReceiver;
                }
            }
        }
        if (document.getElementById('emailTitle')) {
            document.getElementById('emailTitle').root = this;
            document.getElementById('emailTitle').onfocus = function() {
                this.style.color = "#000000";
                if (trim(this.value) == this.root.eTitle) {
                    this.value = "";
                }
            }
            document.getElementById('emailTitle').onblur = function() {
                if (trim(this.value) == "") {
                    this.style.color = "#CCCCCC";
                    this.value = this.root.eTitle;
                }
            }
        }
        if (document.getElementById('emailContent')) {
            if (document.getElementById('emailContent').value == "") {
                document.getElementById('emailContent').value = this.eContent;
            }
            document.getElementById('emailContent').root = this;
            document.getElementById('emailContent').onfocus = function() {
                this.style.color = "#000000";
                if (trim(this.value) == this.root.eContent) {
                    this.value = "";
                }
            }
            document.getElementById('emailContent').onblur = function() {
                if (trim(this.value) == "") {
                    this.style.color = "#CCCCCC";
                    this.value = this.root.eContent;
                }
            }
        }
    }
    this.sendEmail = function() {
        var emExp = /^([a-zA-Z0-9]+[_|\_|\.\-]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
        if (trim(document.getElementById('emailReceiver').value).match(emExp) != null) {
            if (trim(document.getElementById('emailTitle').value.replace(this.eTitle, '')) != "") {
                var emailIframe = document.frames['emailIframe'];
                emailIframe.document.getElementById('emailReceiver').value = trim(document.getElementById('emailReceiver').value.replace(this.eReceiver, ''));
                emailIframe.document.getElementById('emailTitle').value = regHtml(document.getElementById('emailTitle').value.replace(this.eTitle, ''));
                emailIframe.document.getElementById('emailContent').value = regHtml(document.getElementById('emailContent').value.replace(this.eContent, ''));
                emailIframe.document.getElementById('emailUrl').value = location.href;
                emailIframe.document.getElementById('btnSendEmail').click();
                this.turnoff();
                //                this.setInnerHTML();emailUrl
            } else {
                alert('请填写邮件标题');
            }
        } else {
            alert('请输入正确的邮箱地址');
        }
    }
    this.get = function() { }
    if (tool.src) {
        this.imgpath = this.tool.src;
    }
    this.toString = function() {
        return 'REmail';
    }
    this.turnon = function() {
        if (this.isLock) {
            return;
        }
        if (this.innerdiv.innerHTML == "") {
            this.setInnerHTML();
        }
        this.div.style.left = getBoundingClientRect(this.tool).left - 470;
        this.div.style.top = getBoundingClientRect(this.tool).top + 25;
        this.div.style.display = "block";
        this.div.style.visibility = 'visible';
        this.notify('onturnon');
    }
    this.turnoff = function() {
        $("MapmoveTool").className = "unite_MapmoveToolOn";
        this.tool.className = "unite_EMailOff";
        this.isLock = true;
        this.div.style.display = "none";
        this.div.style.visibility = 'hidden';
        if (this.imgpath) {
            this.tool.src = this.imgpath;
        }
        this.notify('onturnoff');
    }
    this.clear = function() { };
    this.setMaplet = function(maplet) {
        this.maplet = maplet;
    }
    this.mClick = function(evt) {
        if (this.div.style.display != "none") {
            var element = null;
            if (window.event) {
                element = window.event.srcElement;
            } else {
                element = evt.originalTarget;
            }
            while (element.tagName != 'BODY') {
                if (element.id == 'REmail' || element.id == this.tool.id) {
                    return;
                }
                element = element.parentElement || element.parentNode;
            }
            this.turnoff();
        }
    }
    if (window.event) {
        g_addListener("click", this.mClick, this);
        document.attachEvent("onclick", g_notify);
    } else {
        g_addListener("click", this.mClick, this);
        document.addEventListener("click", g_notify, false);
    }
    this.onbegin = new Array();
    this.onsuccess = new Array();
    this.onturnon = new Array();
    this.onturnoff = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onbegin':
                if (listener.onbegin) {
                    this.onbegin[this.onbegin.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onsuccess':
                if (listener.onsuccess) {
                    this.onsuccess[this.onsuccess.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnon':
                if (listener.onturnon) {
                    this.onturnon[this.onturnon.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onturnoff':
                if (listener.onturnoff) {
                    this.onturnoff[this.onturnoff.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onbegin':
                for (var i = 0; i < this.onbegin.length; i++) {
                    if (this.onbegin[i].onbegin) {
                        this.onbegin[i].onbegin();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onsuccess':
                for (var i = 0; i < this.onsuccess.length; i++) {
                    if (this.onsuccess[i].onsuccess) {
                        this.onsuccess[i].onsuccess();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnon':
                for (var i = 0; i < this.onturnon.length; i++) {
                    if (this.onturnon[i].onturnon) {
                        this.onturnon[i].onturnon();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onturnoff':
                for (var i = 0; i < this.onturnoff.length; i++) {
                    if (this.onturnoff[i].onturnoff) {
                        this.onturnoff[i].onturnoff();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
g_evt_func = new Array();
function g_addListener(estring, func, target) {
    g_evt_func[g_evt_func.length] = new Object();
    g_evt_func[g_evt_func.length - 1].estring = estring;
    g_evt_func[g_evt_func.length - 1].func = func;
    g_evt_func[g_evt_func.length - 1].target = target;
}
function g_notify(evt) {//debugger
    for (var i = 0; i < g_evt_func.length; i++) {
        if (evt.type == g_evt_func[i].estring) {
            g_evt_func[i].func.apply(g_evt_func[i].target, [evt]);
        }
    }
}
//չ۵鿴ȫϢ
LastPoint = 'info0';
function showAllInfo(poi, int_no) {
    if (int_no == 1) {
        if (document.getElementById(poi).style.display == "") {
            document.getElementById(poi).style.display = "none";
        }
        else if (document.getElementById(poi).style.display == "none") {
            document.getElementById(poi).style.display = "";
            if (LastPoint != poi) {
                document.getElementById(LastPoint).style.display = "none";
            }
        }
    }
    else if (int_no == 2) {
        if (document.getElementById(poi).style.display == "none") {
            document.getElementById(poi).style.display = "";
            if (LastPoint != poi) {
                document.getElementById(LastPoint).style.display = "none";
            }
        }
    }
    LastPoint = poi;
}
//չ۵鿴ȫϢ(sp1)
LastPointID = 'info0';
LastPointMoreID = 'moreInfo0';
sendItem = 1;
function showMoreInfo(ID, int_no, matchType) {
    var thisPointID = 'info' + ID;
    var thisPointMoreID = 'moreInfo' + ID;
    if (int_no == 1) {
        document.getElementById(LastPointID).style.display = "";
        document.getElementById(LastPointMoreID).style.display = "none";
        document.getElementById(thisPointID).style.display = "none";
        document.getElementById(thisPointMoreID).style.display = "";
        LastPointID = thisPointID;
        LastPointMoreID = thisPointMoreID;
        if (matchType != 'nomatch') {
            poiMarker[ID].showBalloonBox();
        }
        parent.sendItem = ID + 1;
    }
    if (int_no == 2) {
        document.getElementById(thisPointID).style.display = "";
        document.getElementById(thisPointMoreID).style.display = "none";
        if (matchType != 'nomatch') {
            poiMarker[ID].hideBalloonBox();
        }
        parent.sendItem = 1;
    }
}
function setHref() {//maps.htmе
    document.getElementById("linkToText").href = document.frames["leftIframe"].viewUrl + '&item=' + sendItem;
}
//д־ѡĳҳĳ
function WriteLog(content, hashId, pageIndex, itemIndex) {
    createXmlHttpLog();
    var url = "/getdatas/writeItemLog.aspx?";
    var strSearch = "";
    var strUrl = content;
    var es = /content=/;
    es.exec(strUrl);
    strSearch += strUrl.getQuery("content");
    //    es=/place=/;
    //    es.exec(strUrl);
    //    var place=strUrl.getQuery("place");
    url += "content=" + escape(strSearch);
    url += "&hashId=" + hashId;
    url += "&pageIndex=" + pageIndex;
    url += "&itemIndex=" + itemIndex;
    url += "&logType=Point";
    url += "&d=" + new Date();
    xmlHttpLog.open("GET", url, true);
    xmlHttpLog.onreadystatechange = processXmlHttpLog;
    xmlHttpLog.send(null);
}
var xmlHttpLog;
function createXmlHttpLog() {
    if (window.ActiveXObject) {
        xmlHttpLog = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttpLog = new XMLHttpRequest();
    }
}
function processXmlHttpLog() {
    if (xmlHttpLog.readyState == 4) {
        var result = xmlHttpLog.responseText;
    }
}
////÷
////ʽȡֵ
//String.prototype.getQuery = function(name)
//{
//    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
//    var r = this.substr(this.indexOf("\?")+1).match(reg);
//    if (r!=null) return unescape(r[2]);
//    return "";
//}
//ʾpoiͼƬ
poiImgDiv = null;
poiImgUrl = null;
function showPoiPicture(thisImg, url) {
    if (!poiImgDiv) {
        poiImgDiv = new RDiv(0, 0, null, null).get();
        document.body.appendChild(poiImgDiv);
    }
    poiImgDiv.style.left = getBoundingClientRect(thisImg.parentNode.parentNode).left;
    poiImgDiv.style.top = getBoundingClientRect(thisImg.parentNode.parentNode).top + 20;
    if (!poiImgUrl) {
        poiImgUrl = new RImage(0, 0, url).get();
        poiImgDiv.appendChild(poiImgUrl);
        poiImgUrl.style.width = "200px";
        poiImgUrl.style.height = "150px";
    }
    else {
        poiImgUrl.src = url;
    }
    poiImgDiv.style.display = "block";
    thisImg.onmouseout = function() {
        poiImgDiv.style.display = "none";
    }
}
/// <summary>
/// ҳ
/// </summary>
/// <param name="thisPage">ǰҳ</param>
/// <param name="total">ܼ¼</param>
/// <param name="thisPageCount">ÿҳʾļ¼</param>
/// <param name="pageCount">ʾҳĿǰҳʾм䣩</param>
/// <param name="strLink">ӵĿҳ</param>
function getPage(thisPage, total, thisPageCount, pageCount, strLink) {
    thisPage = parseInt(thisPage);
    total = parseInt(total);
    thisPageCount = parseInt(thisPageCount);
    pageCount = parseInt(pageCount);
    if (total <= 0) {
        //ʽһ
        //        return "0ҳ/0ҳ һҳ һҳ";
        //ʽ
        return "";
    }
    else {
        //ǰҳʵʾļ¼
        var count = thisPageCount;
        //ֳܹҳ
        var totalPage = 0;
        //޶ҳ루ʾҳ
        var maxPage = 10;
        //ֳܹҳ
        totalPage = Math.floor(total / thisPageCount); //ȡ
        if ((total % thisPageCount) != 0) {
            totalPage = totalPage + 1; //ȡ
            //if(thisPage==totalPage)
            //{
            //    count=total%thisPageCount;
            //}
        }
        if (maxPage != null && maxPage != "" && totalPage > maxPage) {
            totalPage = maxPage;
        }
        //ǰҳڷΧ֮ʾһҳ
        if (thisPage > totalPage || thisPage <= 0) {
            thisPage = 1;
        }
        //ʾҳʼҳstart
        var start = 1;
        if (totalPage <= pageCount) {
            pageCount = totalPage;
        }
        else {
            if (thisPage <= Math.ceil(pageCount / 2)) //pageCountһȡ
            {
                start = 1;
            }
            else {
                if (thisPage > totalPage - Math.floor(pageCount / 2))   //pageCountһȡ
                {
                    start = totalPage - pageCount + 1;
                }
                else {
                    start = thisPage - Math.floor(pageCount / 2);
                }
            }
        }
        var pageHTML = "";
        pageHTML += "<div id='pagination' style='text-align:center; font-size:14;'>";
        //ҳʽһ
        //        for (var iPoint = start; iPoint < (start + pageCount); iPoint++)
        //        {
        //            if (iPoint == thisPage)
        //            {
        //                pageHTML += "<strong><span style='color:#E30502;'>[" + iPoint + "]</span></strong> ";
        //            }
        //            else
        //            {
        //                pageHTML += "<a href='" + strLink + "&skip=" + ((iPoint - 1) * count) + "&count=" + count + "'>[" + iPoint + "]</a> ";
        //            }
        //        }
        //        if (totalPage == 1)
        //        {
        //            pageHTML += "һҳ һҳ";
        //        }
        //        else
        //        {
        //            if (thisPage == 1)
        //            {
        //                pageHTML += "һҳ <a href='" + strLink + "&skip=" + (thisPage * count) + "&count=" + count + "'>һҳ</a>";
        //            }
        //            else if (thisPage == totalPage)
        //            {
        //                pageHTML += "<a href='" + strLink + "&skip=" + ((thisPage - 2) * count) + "&count=" + count + "'>һҳ</a> һҳ";
        //            }
        //            else
        //            {
        //                pageHTML += "<a href='" + strLink + "&skip=" + ((thisPage - 2) * count) + "&count=" + count + "'>һҳ</a> <a href='" + strLink + "&skip=" + (thisPage * count) + "&count=" + count + "'>һҳ</a>";
        //            }
        //        }
        //ҳʽ
        if (totalPage > 1) {
            if (thisPage == 1) {
                pageHTML += escape('ҳ');
            }
            else {
                pageHTML += "<a href='" + strLink + "&skip=" + ((thisPage - 2) * count) + "&count=" + count + "'>" + escape("ҳ") + "</a>";
            }
            for (var iPoint = start; iPoint < (start + pageCount); iPoint++) {
                if (iPoint == thisPage) {
                    pageHTML += "[<strong><span style='color:#E30502;'>" + iPoint + "</span></strong>]";
                }
                else {
                    pageHTML += "[<a href='" + strLink + "&skip=" + ((iPoint - 1) * count) + "&count=" + count + "'>" + iPoint + "</a>]";
                }
            }
            if (thisPage == totalPage) {
                pageHTML += escape("ҳ");
            }
            else {
                pageHTML += "<a href='" + strLink + "&skip=" + (thisPage * count) + "&count=" + count + "'>" + escape("ҳ") + "</a>"
            }
        }
        pageHTML += "</div>";
        return pageHTML;
    }
}
function RBalloon(latlng, zIndex, icon, title, content, maxContent, isNone) {
    this.latlng = latlng;
    this.lat = this.latlng.lat;
    this.lng = this.latlng.lng;
    this.maxContent = maxContent;
    this.zIndex = zIndex;
    this.isNoneMouseMove = isNone; //如果isNone为true，则鼠标移动到标注时没有任何行为
    if (icon) {
        this.icon = icon;
    } else {
        window.status = '创建' + this.toString() + '必须给定icon参数';
    }
    this.title = title;
    this.content = content;
    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    this.style.zIndex = this.zIndex;
    this.labelEnabled = true;
    this.boxEnabled = true;
    this.NORMAL = 0;
    this.LABEL_OPEN = 1;
    this.BOX_OPEN = 2;
    this.state = this.NORMAL;
    this.DragState = false;
    this.img = new RImage(0, 0, this.icon).get();
    this.img.root = this;
    this.img.onload = function() {
        this.style.top = -this.height;
        this.style.left = -10;
    }
    this.img.style.top = -this.img.height;
    this.img.style.left = -10;
    this.div.appendChild(this.img);
    if (this.title && !this.isNoneMouseMove) {
        this.balloonlabel = new RBalloonLabel(JS_SERVER + '/rapi/rwidget/rballoonlabel/img');
        this.balloonlabel.hide();
        this.div.appendChild(this.balloonlabel.get());
        this.img.onmouseover = function() {
            if (!this.root.labelEnabled) {
                return;
            }
            if (this.root.state == this.root.BOX_OPEN) {
                return;
            }
            this.oldzIndex = this.root.div.style.zIndex;
            this.root.div.style.zIndex = 100000;
            if (this.root.balloonlabel) {
                this.root.balloonlabel.setText(this.root.title);
                this.root.balloonlabel.setLocation(this.width / 2, -this.height);
                this.root.balloonlabel.show();
                this.root.state = this.root.LABEL_OPEN;
            }
        }
        this.img.onmouseout = function() {
            if (this.root.balloonlabel) {
                this.root.balloonlabel.hide();
            }
            if (this.root.state == this.root.BOX_OPEN) {
                return;
            }
            this.root.state = this.root.NORMAL;
            this.oldzIndex = (parseInt(this.oldzIndex) > 1000) ? 1000 : this.oldzIndex;
            this.root.div.style.zIndex = this.oldzIndex;
        }
    }
    if (this.content) {
        this.balloonbox = new RBalloonBox(JS_SERVER + '/rapi/rwidget/rballoonbox/img');
        this.balloonbox.hide();
        this.div.appendChild(this.balloonbox.get());
        this.img.onclick = function() {
            if (!this.root.boxEnabled) {
                return;
            }
            if (this.root.balloonbox) {
                this.root.div.style.zIndex = 59999;
                if (this.root.state == this.root.LABEL_OPEN) {
                    this.root.balloonlabel.hide();
                }
                this.root.state = this.root.BOX_OPEN;
                this.root.balloonbox.setTitle(this.root.title);
                this.root.balloonbox.setContent(this.root.content);
                if (this.root.maxContent) {
                    this.root.balloonbox.setMaximizeContent(this.root.maxWidth, this.root.maxHeight, this.root.maxContent);
                }
                this.root.balloonbox.setLocation(this.width / 2, -this.height);
                this.root.balloonbox.show();
            }
            this.root.notify('onclicked');
        }
        this.boxlistener = new Object();
        this.boxlistener.root = this;
        this.boxlistener.onboxclosed = function() {
            this.root.state = this.root.NORMAL;
            this.root.img.oldzIndex = (parseInt(this.root.img.oldzIndex) > 1000) ? 1000 : this.root.img.oldzIndex;
            if (this.root.img.oldzIndex)
                this.root.div.style.zIndex = this.root.img.oldzIndex;
        }
        this.balloonbox.addListener(this.boxlistener, 'onboxclosed');
    } else {
        this.img.onclick = function() {
            this.root.notify('onclicked');
        }
    }
    this.toString = function() {
        return 'RBalloon';
    }
    this.setOffset = function(left, top) {
        this.img.onload = null;
        if (left) {
            this.img.style.left = -left;
        } else {
            this.img.style.left = -this.img.width / 2;
        }
        if (top) {
            this.img.style.top = -top;
        } else {
            this.img.style.top = -this.img.height + 7;
        }
    }
    this.setMaximizeSize = function(width, height) {
        this.maxWidth = width;
        this.maxHeight = height;
    }
    this.setNormalWidth = function(width) {
        if (this.balloonbox) {
            this.balloonbox.setWidth(width);
        }
    }
    this.setNormalHeight = function(height) {
        if (this.balloonbox) {
            this.balloonbox.setHeight(height);
        }
    }
    this.hideBalloonBox = function() {
        if (this.balloonbox) {
            this.balloonbox.hide();
            this.state = this.NORMAL;
            this.img.oldzIndex = (parseInt(this.img.oldzIndex) > 1000) ? 1000 : this.img.oldzIndex;
            this.div.style.zIndex = this.img.oldzIndex;
        }
    }
    this.hideBalloonBoxWithoutEvents = function() {
        if (this.balloonbox) {
            this.balloonbox.hideWithoutEvents();
            this.state = this.NORMAL;
            this.img.oldzIndex = (parseInt(this.img.oldzIndex) > 1000) ? 1000 : this.img.oldzIndex;
            this.div.style.zIndex = this.img.oldzIndex;
        }
    }
    this.showBalloonBox = function() {
        if (this.balloonbox && this.boxEnabled) {
            this.img.onclick();
        }
    }
    this.showBalloonLabel = function() {
        if (this.balloonlabel && this.labelEnabled) {
            this.img.onmouseover();
        }
    }
    this.hideBalloonLabel = function() {
        if (this.balloonlabel) {
            this.img.onmouseout();
        }
    }
    this.disableBalloonLabel = function() {
        this.labelEnabled = false;
    }
    this.enableBalloonLabel = function() {
        this.labelEnabled = true;
    }
    this.disableBalloonBox = function() {
        this.boxEnabled = false;
    }
    this.enableBalloonBox = function() {
        this.boxEnabled = true;
    }
    this.show = function() {
        this.div.style.visibility = 'visible';
    }
    this.hide = function() {
        this.div.style.visibility = 'hidden';
    }
    this.enableDrag = function() {
        this.disableBalloonBox();
        this.disableBalloonLabel();
        this.hideBalloonBoxWithoutEvents();
        this.hideBalloonLabel();
        this.img.root = this;
        this.img.style.cursor = "move";
        this.img.onmousedown = function() {
            this.xoffset = event.clientX - parseInt(this.root.div.style.left, 10);
            this.yoffset = event.clientY - parseInt(this.root.div.style.top, 10);
            this.setCapture();
            this.root.DragState = true;
            this.onmousemove = function() {
                if (this.root.DragState) {
                    this.root.div.style.left = event.clientX - this.xoffset;
                    this.root.div.style.top = event.clientY - this.yoffset;
                }
            }
        }
        this.img.onmouseup = function() {
            this.releaseCapture();
            this.onmousemove = null;
            this.root.notify('onDragEnd');
        }
    }
    this.disableDrag = function() {
        this.DragState = false;
        this.enableBalloonBox();
        this.enableBalloonLabel();
        this.img.onmousedown = null;
        this.img.onmouseup = null;
        this.img.style.cursor = "default";
    }
    this.onclicked = new Array();
    this.onDragEnd = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onboxclosed':
                if (this.balloonbox) {
                    this.balloonbox.addListener(listener, estring);
                }
                break;
            case 'onmaxboxclosed':
                if (this.balloonbox) {
                    this.balloonbox.addListener(listener, estring);
                }
                break;
            case 'onminboxclosed':
                if (this.balloonbox) {
                    this.balloonbox.addListener(listener, estring);
                }
                break;
            case 'onboxopened':
                if (this.balloonbox) {
                    this.balloonbox.addListener(listener, estring);
                }
                break;
            case 'onboxmaximized':
                if (this.balloonbox) {
                    this.balloonbox.addListener(listener, estring);
                }
                break;
            case 'onboxrestored':
                if (this.balloonbox) {
                    this.balloonbox.addListener(listener, estring);
                }
                break;
            case 'onboxresized':
                if (this.balloonbox) {
                    this.balloonbox.addListener(listener, estring);
                }
                break;
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onDragEnd':
                if (listener.onDragEnd) {
                    this.onDragEnd[this.onDragEnd.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onDragEnd':
                for (var i = 0; i < this.onDragEnd.length; i++) {
                    if (this.onDragEnd[i].onDragEnd) {
                        this.onDragEnd[i].onDragEnd();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.setContent = function(content) {
        this.content = content;
        if (this.balloonbox) {
            this.balloonbox.setContent(this.content);
        }
    }
    this.setMaxContent = function(maxContent) {
        this.maxContent = maxContent;
        if (this.balloonbox) {
            this.balloonbox.setContent(this.maxContent);
        }
    }
    this.setTitle = function(title) {
        this.title = title;
        if (this.balloonbox) {
            this.balloonbox.setTitle(this.title);
        }
    }
    this.destroy = function() {
        if (this.div) {
            this.div.innerHTML = "";
            if (this.div.parentNode) {
                this.div.parentNode.removeChild(this.div);
            }
            this.div = null;
        }
        this.toString = function() { return 'DestroyedBalloonMarker' };
    }
    this.setBounds = function(bounds) {
        if (this.balloonlabel) {
            this.balloonlabel.setBounds(bounds);
        }
    }
}
function RBalloonBox(imgsrc) {
    this.imgsrc = imgsrc;
    this.defaultWidth = 400;
    this.defaultHeight = 180;
    this.width = this.defaultWidth;
    this.height = this.defaultHeight;
    this.IsMax = false;
    this.IsHide = true;
    this.div = new RDiv(0, 0, null, null).get();
    this.innerdiv = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdiv);
    this.innerdivFoot = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdivFoot);
    this.style = this.div.style;
    if (!this.closebtn) {
        this.closebtn = new RImage(this.width - 30, 13, this.imgsrc + '/close.gif').get();
    }
    this.closebtn.style.cursor = 'pointer';
    this.closebtn.root = this;
    this.div.appendChild(this.closebtn);
    this.closebtn.onclick = function() {
        this.root.width = this.root.defaultWidth;
        this.root.height = this.root.defaultHeight;
        this.root.hide();
        this.root.setContent('');
        this.root.innerdiv.innerHTML = '';
        this.root.innerdivFoot.innerHTML = "";
    }
    this.setInnerHTML = function() {
        if (!this.currentTitle) {
            this.title = '瑞图资讯';
        }
        if (!this.currentContent) {
            this.currentContent = '暂无详情';
        }
        if (this.suggestWidth) {
            this.width = this.suggestWidth;
        } else {
            var titlelength = getInnerText(this.title).length;
            if (titlelength * 13 + 100 > this.defaultWidth) {
                this.width = titlelength * 13 + 100;
            }
        }
        if (this.suggestHeight) {
            this.height = this.suggestHeight;
        }
        if (this.closebtn) {
            this.closebtn.style.left = this.width - 30;
        }
        if (this.maxibtn) {
            this.maxibtn.style.left = this.width - 50;
        }
        this.innerdiv.innerHTML = '<table width="' + this.width + '" height="' + (parseInt(this.height) - 37) + '" style="" cellpadding="0" cellspacing="0" border="0">' +
'<tr>' +
'<td width="10" height="10" style="background-image:url(' + this.imgsrc + '/balloon_01.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_02.gif);background-repeat:repeat-x">' +
'</td>' +
'<td width="10" style="background-image:url(' + this.imgsrc + '/balloon_04.gif);background-Repeat:no-repeat">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td  height="22" style="background-image:url(' + this.imgsrc + '/balloon_05.gif);background-repeat:repeat-y">' +
'</td>' +
'<td id="poiInfoBoxTitle" style="background-color:#FDE5B7;font-size:12px;font-family:宋体;font-weight:bold;" align="center">' +
this.currentTitle +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_07.gif);background-repeat:repeat-y">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td height="1" style="background-image:url(' + this.imgsrc + '/balloon_10.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_11.gif);background-repeat:repeat-x">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_12.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_13.gif);background-repeat:repeat-y">' +
'</td>' +
'<td style="font-size:12px;font-family:宋体;background-color:#FFFDF2">' +
'<div id="poiInfoBox" style="width:' + (this.width - 20) + ';height:' + (this.height - 80) + ';overflow:auto">' +
this.currentContent +
'</div>' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_15.gif);background-repeat:repeat-y">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td height="10" style="background-image:url(' + this.imgsrc + '/balloon_18.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_19.gif);background-repeat:repeat-x" align="center">' +
        //						'<img src="'+this.imgsrc+'/balloon_21.gif" width="13" height="47" unselectable="on" border="0">'+
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloon_23.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'</table>';
        this.innerdivFoot.style.left = (parseInt(this.width) - 13) / 2;
        this.innerdivFoot.style.top = parseInt(this.height) - 47;
        this.innerdivFoot.innerHTML = '<table width="13" height="47" cellpadding="0" cellspacing="0" border="0">' +
'<tr><td ><img src="' + this.imgsrc + '/balloon_21.gif" width="13" height="47" unselectable="on" border="0">' +
'</td>' +
'</tr>' +
'</table>';
    }
    this.setTitle = function(title) {
        this.title = title;
        this.currentTitle = this.title;
        this.setInnerHTML();
    }
    this.setContent = function(content) {
        this.content = content;
        this.currentContent = this.content;
        this.setInnerHTML();
    }
    this.setWidth = function(width) {
        this.suggestWidth = width;
        this.setInnerHTML();
    }
    this.setHeight = function(height) {
        this.suggestHeight = height;
        this.height = height;
        this.setInnerHTML();
    }
    this.resize = function(width, height) {
        this.setWidth(width);
        this.setHeight(height);
        this.notify('onboxresized');
    }
    this.setAutoResize = function(flag) {
        if (flag) {
            this.suggestWidth = null;
            this.suggestHeight = null;
        } else {
            if (!this.suggestWidth) {
                this.suggestWidth = this.defaultWidth;
            }
            if (!this.suggestHeight) {
                this.suggestHeight = this.defaultHeight;
            }
            this.setInnerHTML();
        }
    }
    this.toString = function() {
        return 'RBalloonBox';
    }
    this.get = function() {
        return this.div;
    }
    this.setLocation = function(left, top) {
        this.left = left;
        this.top = top;
        this.style.left = this.left - this.width / 2 - 10;
        this.style.top = this.top - this.height;
    }
    this.hide = function() {
        if (this.IsMax && !this.IsHide) {
            this.restore();
            this.notify('onmaxboxclosed');
        } else if (!this.IsMax && !this.IsHide) {
            this.notify('onminboxclosed');
        }
        this.notify('onboxclosed');
        this.hideWithoutEvents();
    }
    this.hideWithoutEvents = function() {
        this.style.visibility = 'hidden';
        this.IsMax = false;
        this.IsHide = true;
        if (this.maxibtn) {
            this.maxibtn.src = this.imgsrc + '/maximize.gif';
        }
        if (this.currentTitle) {
            this.setAutoResize(true);
        }
        this.innerdiv.innerHTML = "";
    }
    this.show = function() {
        this.defaultWidth = this.width;
        this.defaultHeight = this.height;
        this.style.visibility = 'visible';
        this.IsHide = false;
        this.notify('onboxopened');
    }
    this.setMaximizeContent = function(width, height, maxContent) {
        if (!width || !height || !maxContent) {
            return;
        }
        this.maxWidth = width;
        this.maxHeight = height;
        this.maxContent = maxContent;
        if (this.maxContent) {
            if (!this.maxibtn) {
                this.maxibtn = new RImage(this.width - 50, 13, this.imgsrc + '/maximize.gif').get();
                this.maxibtn.style.cursor = 'pointer';
            }
            this.maxibtn.root = this;
            this.maxibtn.onclick = function() {
                this.root.maximize();
            }
            this.div.appendChild(this.maxibtn);
        }
    }
    this.maximize = function() {
        if (this.maxWidth && this.maxHeight && this.maxContent) {
            this.IsMax = true;
            this.defaultWidth = this.width;
            this.defaultHeight = this.height;
            this.setWidth(this.maxWidth);
            this.setHeight(this.maxHeight);
            this.currentContent = "正在载入...";
            this.setInnerHTML();
            this.currentContent = this.maxContent;
            setRTimeout(this, this.setInnerHTML, 1000);
            this.maxibtn.src = this.imgsrc + '/restore.gif';
            this.maxibtn.style.left = this.width - 50;
            this.closebtn.style.left = this.width - 30;
            this.maxibtn.onclick = function() {
                this.root.restore();
            }
            this.setLocation(this.left, this.top);
            this.notify('onboxmaximized');
        }
    }
    this.restore = function() {
        this.IsMax = false;
        this.setAutoResize(true);
        this.width = this.defaultWidth;
        this.height = this.defaultHeight;
        this.currentContent = this.content;
        this.setInnerHTML();
        this.maxibtn.src = this.imgsrc + '/maximize.gif';
        this.maxibtn.style.left = this.width - 50;
        this.maxibtn.onclick = function() {
            this.root.maximize();
        }
        this.closebtn.style.left = this.width - 30;
        this.setLocation(this.left, this.top);
        this.notify('onboxrestored');
    }
    this.onmaxboxclosed = new Array();
    this.onminboxclosed = new Array();
    this.onboxclosed = new Array();
    this.onboxopened = new Array();
    this.onboxmaximized = new Array();
    this.onboxrestored = new Array();
    this.onboxresized = new Array();
    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onboxclosed':
                if (listener.onboxclosed) {
                    this.onboxclosed[this.onboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onmaxboxclosed':
                if (listener.onmaxboxclosed) {
                    this.onmaxboxclosed[this.onmaxboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onminboxclosed':
                if (listener.onminboxclosed) {
                    this.onminboxclosed[this.onminboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxopened':
                if (listener.onboxopened) {
                    this.onboxopened[this.onboxopened.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxmaximized':
                if (listener.onboxmaximized) {
                    this.onboxmaximized[this.onboxmaximized.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxrestored':
                if (listener.onboxrestored) {
                    this.onboxrestored[this.onboxrestored.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxresized':
                if (listener.onboxresized) {
                    this.onboxresized[this.onboxresized.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
    this.notify = function(estring) {
        switch (estring) {
            case 'onboxopened':
                for (var i = 0; i < this.onboxopened.length; i++) {
                    if (this.onboxopened[i].onboxopened) {
                        this.onboxopened[i].onboxopened();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxclosed':
                for (var i = 0; i < this.onboxclosed.length; i++) {
                    if (this.onboxclosed[i].onboxclosed) {
                        this.onboxclosed[i].onboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onmaxboxclosed':
                for (var i = 0; i < this.onmaxboxclosed.length; i++) {
                    if (this.onmaxboxclosed[i].onmaxboxclosed) {
                        this.onmaxboxclosed[i].onmaxboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onminboxclosed':
                for (var i = 0; i < this.onminboxclosed.length; i++) {
                    if (this.onminboxclosed[i].onminboxclosed) {
                        this.onminboxclosed[i].onminboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxmaximized':
                for (var i = 0; i < this.onboxmaximized.length; i++) {
                    if (this.onboxmaximized[i].onboxmaximized) {
                        this.onboxmaximized[i].onboxmaximized();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxrestored':
                for (var i = 0; i < this.onboxrestored.length; i++) {
                    if (this.onboxrestored[i].onboxrestored) {
                        this.onboxrestored[i].onboxrestored();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxresized':
                for (var i = 0; i < this.onboxresized.length; i++) {
                    if (this.onboxresized[i].onboxresized) {
                        this.onboxresized[i].onboxresized();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}
function RBalloonLabel(imgsrc) {
    this.imgsrc = imgsrc;
    this.left = 0;
    this.top = 0;
    this.defaultWidth = 60;
    this.defaultHeight = 79;
    this.width = 60;
    this.height = 70;
    this.hasbounds = false;
    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    this.setInnerHTML = function(text) {
        this.text = text;
        var textlength = getInnerText(text).length;
        if (textlength * 13 + 40 > this.defaultWidth) {
            this.width = textlength * 14 + 40;
        }
        this.div.style.width = this.width;
        this.div.innerHTML = '<table border="0" cellspacing="0" cellpadding="0" width="' + this.width + '">' +
'<tr>' +
'<td width="9" height="9" style="background-image:url(' + this.imgsrc + '/balloonlabel_01.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloonlabel_03.gif);background-repeat:repeat-x">' +
'</td>' +
'<td width="10" style="background-image:url(' + this.imgsrc + '/balloonlabel_04.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td height="22" style="background-image:url(' + this.imgsrc + '/balloonlabel_05.gif);background-repeat:repeat-y">' +
'</td>' +
'<td style="background-color:#FDE5B7;font-size:12px;font-family:宋体;font-weight:bold" align="center">' +
this.text +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloonlabel_07.gif);background-repeat:repeat-y">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td height="39" style="background-image:url(' + this.imgsrc + '/balloonlabel_10.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloonlabel_11.gif);background-repeat:repeat-x" align="center">' +
'<img src="' + this.imgsrc + '/balloonlabel_13.gif" width="12" height="39" unselectable="on"></td>' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/balloonlabel_15.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'</table>';
        if (this.hasbounds && this.isOverflowed()) {
            this.setLocation(this.left, this.height + this.top + 20);
            this.div.innerHTML = '<table border="0" cellspacing="0" cellpadding="0" width="' + this.width + '">' +
'<tr>' +
'<td height="39" width="9" style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_10.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_11.gif);background-repeat:repeat-x" align="center" width="' + (this.width - 19) + '">' +
'<img src="' + this.imgsrc + '/reverse_balloonlabel_13.gif" width="12" height="39" unselectable="on"></td>' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_15.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td height="22" style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_05.gif);background-repeat:repeat-y">' +
'</td>' +
'<td style="background-color:#FDE5B7;font-size:12px;font-family:宋体;font-weight:bold" align="center" width="' + (this.width - 19) + '">' +
this.text +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_07.gif);background-repeat:repeat-y">' +
'</td>' +
'</tr>' +
'<tr>' +
'<td width="9" height="9" style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_01.gif);background-repeat:no-repeat">' +
'</td>' +
'<td style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_03.gif);background-repeat:repeat-x" width="' + (this.width - 19) + '">' +
'</td>' +
'<td width="10" style="background-image:url(' + this.imgsrc + '/reverse_balloonlabel_04.gif);background-repeat:no-repeat">' +
'</td>' +
'</tr>' +
'</table>';
        }
    }
    this.setText = function(text) {
        this.text = text;
        this.setInnerHTML(this.text);
    }
    this.getText = function() {
        return this.text;
    }
    this.toString = function() {
        return 'RBalloonLabel';
    }
    this.get = function() {
        return this.div;
    }
    this.setLocation = function(left, top) {
        this.left = left;
        this.top = top;
        this.style.left = left - this.width / 2 - 10;
        this.style.top = top - this.height;
    }
    this.hide = function() {
        this.style.visibility = 'hidden';
    }
    this.show = function() {
        this.style.visibility = 'visible';
        this.setText(this.text);
    }
    this.setBounds = function(bounds) {
        this.hasbounds = true;
        this.bounds = bounds;
    }
    this.isOverflowed = function() {
        var tmpBounds = getBoundingClientRect(this.div);
        if (tmpBounds.top < this.bounds.top) {
            return true;
        }
        return false;
    }
}

function RMengniuBox(imgsrc) {
    this.isOpen = false;
    this.isMaxBox = false;
    this.imgsrc = imgsrc;
    this.content = "";
    this.maxContent = "";

    this.towAdWidth = 370;
    this.towAdHeight = 340;
    this.rightAdWidth = 370;
    this.rightAdHeight = 230;
    this.noAdWidth = 320;
    this.noAdHeight = 260;

    this.mengniuWidth = 420;
    this.mengniuHeight = 350;

    this.width = this.rightAdWidth;
    this.height = this.rightAdHeight;

    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;

    this.innerdiv = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdiv);

    this.innerdivFoot = new RDiv(0, 0, null, null).get();
    this.div.appendChild(this.innerdivFoot);

    if (!this.closebtn) {
        this.closebtn = new RImage(0, 13, this.imgsrc + '/close.gif').get();
        this.closebtn.style.display = "none";
    }
    this.closebtn.style.cursor = 'pointer';
    this.closebtn.root = this;
    this.div.appendChild(this.closebtn);

    this.closebtn.onclick = function() {
        this.root.hide();
        this.root.innerdiv.innerHTML = '';
        this.root.innerdivFoot.innerHTML = "";
    }

    this.setContent = function(num, title, content) {
        this.title = title;
        this.content = content;
        switch (num) {
            case 1:
                this.width = this.towAdWidth;
                this.height = this.towAdHeight;
                break;
            case 2:
                this.width = this.rightAdWidth;
                this.height = this.rightAdHeight;
                break;
            case 3:
                this.width = this.noAdWidth;
                this.height = this.noAdHeight;
                break;
            case 4:
                this.width = this.mengniuWidth;
                this.height = this.mengniuHeight;
                break;

            default:
                this.width = this.rightAdWidth;
                this.height = this.rightAdHeight;
                break;
        }

        this.setInnerHTML(this.width, this.height, this.title, this.content);
    }

    this.setMaximizeContent = function(width, height, maxContent) {
        if (!width || !height || !maxContent) {
            return;
        }
        this.maxWidth = width;
        this.maxHeight = height;
        this.maxContent = maxContent;
        if (this.maxContent) {
            if (!this.maxibtn) {
                this.maxibtn = new RImage(this.width - 50, 13, this.imgsrc + '/maximize.gif').get();
                this.maxibtn.style.cursor = 'pointer';
            }
            this.maxibtn.root = this;
            this.maxibtn.onclick = function() {
                this.root.maximize();
            }
            this.div.appendChild(this.maxibtn);
        }
    }

    this.maximize = function() {
        if (this.maxWidth && this.maxHeight && this.maxContent) {
            this.isMaxBox = true;
            this.setInnerHTML(this.maxWidth, this.maxHeight, this.title, this.maxContent);
            this.maxibtn.src = this.imgsrc + '/restore.gif';
            this.maxibtn.onclick = function() {
                this.root.restore();
            }
            this.setLocation(this.left, this.top);
            this.notify('onboxmaximized');
        }
    }

    this.restore = function() {
        this.isMaxBox = false;
        this.setInnerHTML(this.width, this.height, this.title, this.content);
        this.maxibtn.src = this.imgsrc + '/maximize.gif';
        this.maxibtn.onclick = function() {
            this.root.maximize();
        }
        this.setLocation(this.left, this.top);
        this.notify('onboxrestored');
    }

    this.setInnerHTML = function(width, height, title, content) {
        if (this.closebtn) {
            this.closebtn.style.left = width - 30;
            this.closebtn.style.display = "block";
        }
        if (this.maxibtn) {
            this.maxibtn.style.left = width - 50;
        }

        this.innerdiv.innerHTML = '<table width="' + width + '" height="' + (parseInt(height) - 37) + '" style="" cellpadding="0" cellspacing="0" border="0">' +
				'<tr>' +
					'<td width="10" height="10" style="background-image:url(' + this.imgsrc + '/balloon_01.gif);background-repeat:no-repeat">' +
					'</td>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_02.gif);background-repeat:repeat-x">' +
					'</td>' +
					'<td width="10" style="background-image:url(' + this.imgsrc + '/balloon_04.gif);background-Repeat:no-repeat">' +
					'</td>' +
				'</tr>' +
				'<tr>' +
					'<td  height="22" style="background-image:url(' + this.imgsrc + '/balloon_05.gif);background-repeat:repeat-y">' +
					'</td>' +
					'<td id="" style="background-color:#FDE5B7;font-size:12px;font-family:宋体;font-weight:bold;" align="left">' +
					'<div style="margin-left:10px;">' + title + '</div>' +
					'</td>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_07.gif);background-repeat:repeat-y">' +
					'</td>' +
				'</tr>' +
				'<tr>' +
					'<td height="1" style="background-image:url(' + this.imgsrc + '/balloon_10.gif);background-repeat:no-repeat">' +
					'</td>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_11.gif);background-repeat:repeat-x">' +
					'</td>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_12.gif);background-repeat:no-repeat">' +
					'</td>' +
				'</tr>' +
				'<tr>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_13.gif);background-repeat:repeat-y">' +
					'</td>' +
					'<td style="font-size:12px;font-family:宋体;background-color:#FFFDF2">' +
						'<div id="" style="width:' + (width - 20) + ';height:' + (height - 80) + ';overflow:auto; padding:5px 10px;">' +
							content +
						'</div>' +
	                '</td>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_15.gif);background-repeat:repeat-y">' +
					'</td>' +
				'</tr>' +
				'<tr>' +
					'<td height="10" style="background-image:url(' + this.imgsrc + '/balloon_18.gif);background-repeat:no-repeat">' +
					'</td>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_19.gif);background-repeat:repeat-x" align="center">' +
        //						'<img src="'+this.imgsrc+'/balloon_21.gif" width="13" height="47" unselectable="on" border="0">'+
					'</td>' +
					'<td style="background-image:url(' + this.imgsrc + '/balloon_23.gif);background-repeat:no-repeat">' +
					'</td>' +
				'</tr>' +
			'</table>';

        this.innerdivFoot.style.left = (parseInt(width) - 13) / 2;
        this.innerdivFoot.style.top = parseInt(height) - 47;
        this.innerdivFoot.innerHTML = '<table width="13" height="47" cellpadding="0" cellspacing="0" border="0">' +
			    '<tr><td ><img src="' + this.imgsrc + '/balloon_21.gif" width="13" height="47" unselectable="on" border="0">' +
			    '</td>' +
				'</tr>' +
			'</table>';
    }

    this.setLocation = function(left, top) {
        this.left = left;
        this.top = top;
        if (this.isMaxBox) {
            this.style.left = this.left - this.maxWidth / 2;
            this.style.top = this.top - this.maxHeight;
        } else {
            this.style.left = this.left - this.width / 2;
            this.style.top = this.top - this.height;
        }

    }

    this.setLocationMaxbox = function(left, top) {
        this.left = left;
        this.top = top;
        this.style.left = this.left - this.maxWidth / 2;
        this.style.top = this.top - this.maxHeight;
    }

    this.hide = function() {

        this.notify('onboxclosed');
        this.hideWithoutEvents();
    }

    this.hideWithoutEvents = function() {
        this.style.visibility = 'hidden';
        this.isOpen = false;

        this.innerdiv.innerHTML = "";
    }

    this.show = function() {
        this.style.visibility = 'visible';
        this.isOpen = true;
        this.notify('onboxopened');
    }

    this.get = function() {
        return this.div;
    }

    this.onmaxboxclosed = new Array();
    this.onminboxclosed = new Array();
    this.onboxclosed = new Array();
    this.onboxopened = new Array();
    this.onboxmaximized = new Array();
    this.onboxrestored = new Array();
    this.onboxresized = new Array();

    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onboxclosed':
                if (listener.onboxclosed) {
                    this.onboxclosed[this.onboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onmaxboxclosed':
                if (listener.onmaxboxclosed) {
                    this.onmaxboxclosed[this.onmaxboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onminboxclosed':
                if (listener.onminboxclosed) {
                    this.onminboxclosed[this.onminboxclosed.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxopened':
                if (listener.onboxopened) {
                    this.onboxopened[this.onboxopened.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxmaximized':
                if (listener.onboxmaximized) {
                    this.onboxmaximized[this.onboxmaximized.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxrestored':
                if (listener.onboxrestored) {
                    this.onboxrestored[this.onboxrestored.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onboxresized':
                if (listener.onboxresized) {
                    this.onboxresized[this.onboxresized.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }

    this.notify = function(estring) {
        switch (estring) {
            case 'onboxopened':
                for (var i = 0; i < this.onboxopened.length; i++) {
                    if (this.onboxopened[i].onboxopened) {
                        this.onboxopened[i].onboxopened();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxclosed':
                for (var i = 0; i < this.onboxclosed.length; i++) {
                    if (this.onboxclosed[i].onboxclosed) {
                        this.onboxclosed[i].onboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onmaxboxclosed':
                for (var i = 0; i < this.onmaxboxclosed.length; i++) {
                    if (this.onmaxboxclosed[i].onmaxboxclosed) {
                        this.onmaxboxclosed[i].onmaxboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onminboxclosed':
                for (var i = 0; i < this.onminboxclosed.length; i++) {
                    if (this.onminboxclosed[i].onminboxclosed) {
                        this.onminboxclosed[i].onminboxclosed();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxmaximized':
                for (var i = 0; i < this.onboxmaximized.length; i++) {
                    if (this.onboxmaximized[i].onboxmaximized) {
                        this.onboxmaximized[i].onboxmaximized();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxrestored':
                for (var i = 0; i < this.onboxrestored.length; i++) {
                    if (this.onboxrestored[i].onboxrestored) {
                        this.onboxrestored[i].onboxrestored();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onboxresized':
                for (var i = 0; i < this.onboxresized.length; i++) {
                    if (this.onboxresized[i].onboxresized) {
                        this.onboxresized[i].onboxresized();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}


function RMengniu(maplet, minLatlng, maxLatlng, zIndex, fillcolor, strokecolor, opacity, boxType, title, content, maxContent) {
    this.maplet = maplet;

    //    this.latlngDistance = 0.000218;

    this.leftbottom = minLatlng;
    this.righttop = maxLatlng;

    this.lat = (this.leftbottom.lat * 1000000 + this.righttop.lat * 1000000) / 2000000;
    this.lng = (this.leftbottom.lng * 1000000 + this.righttop.lng * 1000000) / 2000000;
    this.latlng = new Object();
    this.latlng.lat = this.lat;
    this.latlng.lng = this.lng;
    this.isOpenBalloon = false;

    this.zIndex = zIndex;

    this.title = title;
    this.content = content;
    this.maxContent = maxContent;
    this.boxType = boxType;

    this.div = new RDiv(0, 0, null, null).get();
    this.style = this.div.style;
    this.style.zIndex = this.zIndex;

    if (title) {
        this.type = "Region";

        this.bounds = new Object();
        this.bounds.leftbottom = this.leftbottom;
        this.bounds.righttop = this.righttop;

        this.areaDiv = new RDiv(0, 0, null, null).get();
        this.div.appendChild(this.areaDiv);
        this.areaDiv.style.cursor = "pointer";
        if (this.areaDiv.addEventListener) {
            this.svg = document.createElementNS(SVG_URL, "svg");
            this.svg.setAttribute("version", "1.1");
            this.svg.setAttribute("overflow", "visible");
            this.rect = document.createElementNS(SVG_URL, "rect");
            if (fillcolor) {
                this.rect.setAttribute("fill", fillcolor);
            } else {
                this.rect.setAttribute("fill", "none")
            }
            this.rect.setAttribute("fill-opacity", 0);
            if (strokecolor) {
                this.rect.setAttribute("stroke", strokecolor);
            } else {
                this.rect.setAttribute("stroke", "#000000");
            }
            this.rect.setAttribute("stroke-opacity", 0);
            this.rect.setAttribute("stroke-width", 0);

            this.areaDiv.appendChild(this.svg);
            this.svg.appendChild(this.rect);
        } else {
            this.rect = document.createElement("v:rect");
            this.rect.unselectable = 'on';
            this.style = this.rect.style;

            if (strokecolor) {
                this.rect.strokecolor = strokecolor;
            } else {
                this.rect.strokecolor = "#000000";
            }

            if (fillcolor) {
                this.rect.fillcolor = fillcolor;
            } else {
                this.rect.filled = "false";
            }

            this.rect.strokeweight = 0; //边框宽

            if (opacity) {
                this.style.filter = 'alpha(opacity=' + (opacity * 100) + ')';
            } else {
                this.style.filter = 'alpha(opacity=0)';
            }
            this.areaDiv.appendChild(this.rect);
        }

        this.gpsidAreaBox = new RMengniuBox(JS_SERVER + '/rapi/rwidget/rgpsidareabox/img');
        this.div.appendChild(this.gpsidAreaBox.get());
        this.areaDiv.root = this;
        this.areaDiv.onclick = function() {
            if (this.root.gpsidAreaBox.isMaxBox) {
                this.root.gpsidAreaBox.isMaxBox = false;
                if (this.root.gpsidAreaBox.maxibtn) {
                    this.root.gpsidAreaBox.maxibtn.src = this.root.gpsidAreaBox.imgsrc + '/maximize.gif';
                }
            }
            if (this.root.gpsidAreaBox) {
                this.root.gpsidAreaBox.setContent(this.root.boxType, this.root.title, this.root.content);
                this.root.div.style.zIndex = 59999;
                if (this.root.maxContent) {
                    this.root.gpsidAreaBox.setMaximizeContent(this.root.maxWidth, this.root.maxHeight, this.root.maxContent);
                }

                var tmp1 = this.root.maplet.getPixel(this.root.leftbottom.lat, this.root.leftbottom.lng);
                var tmp2 = this.root.maplet.getPixel(this.root.righttop.lat, this.root.righttop.lng);
                var width = Math.abs(tmp2.left - tmp1.left);
                var height = Math.abs(tmp2.top - tmp1.top);
                this.root.gpsidAreaBox.setLocation((width + 8) / 2, height / 2);

                this.root.gpsidAreaBox.show();
            }
            this.root.notify('onclicked');
        }
    } else {
        this.areaDiv.onclick = function() {
            this.root.notify('onclicked');
        }
    }

    this.setMaximizeSize = function(width, height) {
        this.maxWidth = width;
        this.maxHeight = height;
    }

    this.hideBalloonBoxWithoutEvents = function() {
        if (this.gpsidAreaBox) {
            this.gpsidAreaBox.hideWithoutEvents();
        }
    }

    this.toString = function() {
        return 'RGpsidArea';
    }
    this.get = function() {
        return this.div;
    }

    this.onclicked = new Array();
    this.onDragEnd = new Array();

    this.addListener = function(listener, estring) {
        switch (estring) {
            case 'onboxclosed':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onmaxboxclosed':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onminboxclosed':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxopened':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxmaximized':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxrestored':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onboxresized':
                if (this.gpsidAreaBox) {
                    this.gpsidAreaBox.addListener(listener, estring);
                }
                break;
            case 'onclicked':
                if (listener.onclicked) {
                    this.onclicked[this.onclicked.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            case 'onDragEnd':
                if (listener.onDragEnd) {
                    this.onDragEnd[this.onDragEnd.length] = listener;
                } else {
                    window.status = this.toString() + ':不合法的' + estring + '事件对象';
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }

    this.destroy = function() {
        if (this.div) {
            this.div.innerHTML = "";
            if (this.div.parentNode) {
                this.div.parentNode.removeChild(this.div);
            }
            this.div = null;
        }
        this.toString = function() { return 'DestroyedRMengniuMarker' };
    }

    this.notify = function(estring) {
        switch (estring) {
            case 'onclicked':
                for (var i = 0; i < this.onclicked.length; i++) {
                    if (this.onclicked[i].onclicked) {
                        this.onclicked[i].onclicked();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            case 'onDragEnd':
                for (var i = 0; i < this.onDragEnd.length; i++) {
                    if (this.onDragEnd[i].onDragEnd) {
                        this.onDragEnd[i].onDragEnd();
                    } else {
                        window.status = this.toString() + '类的某' + estring + '事件监听对象损坏';
                    }
                }
                break;
            default:
                window.status = this.toString() + '类不存在' + estring + '事件';
                break;
        }
    }
}

function mengniuInnerHTML(poi) {
    var htmlAry = new Array();
    htmlAry.push("<div style='clear:both; width:100%; height:90px; overflow:auto;'>" + poi.content + "</div>");
    htmlAry.push("<div style='clear:both; width:100%; height:80px; border-top:solid 1px #E1EFB4; margin-top:3px; overflow:auto;'>");
    htmlAry.push("<div style='clear:both; float:left; width:10px; padding-top:8px; color:#99CC00; font-weight:700; text-align:center;'>全景图像</div>");
    for (var i = 0; i < poi.img.length; i++) {
        htmlAry.push("<div style='float:left; padding:2px 0px 0px 5px;text-align:center;'><div><img src='" + poi.img[i].src + "' style='width:60px; height:60px; cursor:pointer;' onclick='window.open(\"" + poi.img[i].url + "\",\"_blank\")'></div><div style=''>" + poi.img[i].title + "</div></div>");
    }
    htmlAry.push("</div>");
    htmlAry.push("<div style='clear:both; width:100%; height:80px; border-top:solid 1px #E1EFB4; margin-top:3px; overflow:auto;'>");
    htmlAry.push("<div style='clear:both; float:left; width:10px; padding-top:8px; color:#99CC00; font-weight:700; text-align:center;'>全景视频</div>");
    for (var i = 0; i < poi.video.length; i++) {
        htmlAry.push("<div style='float:left; padding:2px 0px 0px 5px;text-align:center;'><div><img src='" + poi.video[i].src + "' style='width:60px; height:60px; cursor:pointer;' onclick='window.open(\"" + poi.video[i].url + "\",\"_blank\")'></div><div style=''>" + poi.video[i].title + "</div></div>");
    }
    htmlAry.push("</div>");
    return htmlAry.join("");
}
function setRTimeout(target, func, delay, args) {
    if (args) {
        if (target) {
            window.setTimeout(function() { func.apply(target, args); }, delay);
        }
    } else {
        if (target) {
            window.setTimeout(function() { func.apply(target); }, delay);
        }
    }
}
function getBoundingClientRect(element) {
    if (element) {
        var bounds = new Object();
        if (!document.addEventListener) {
            bounds = element.getBoundingClientRect();
        } else {
            bounds.left = element.offsetLeft;
            bounds.top = element.offsetTop;
            bounds.right = element.offsetLeft + element.offsetWidth;
            bounds.bottom = element.offsetTop + element.offsetHeight;
        }
        return bounds;
    } else {
        return null;
    }
}
function getInnerText(str) {
    var div = new RDiv().get();
    div.innerHTML = str;
    if (!div.addEventListener) {
        return div.innerText;
    } else {
        return div.textContent;
    }
}
function innerText(element) {
    if (window.event) {
        return element.innerText;
    } else {
        return element.textContent;
    }
}
//长度，面积计算相关
//importClass('rapi.rbase.RCoordinate');
function getPathDistance(latlngs) {
    var distances = 0;
    for (var pointCursor = 0; pointCursor < latlngs.length - 1; pointCursor++) {
        distances += distanceBetween(latlngs[pointCursor], latlngs[pointCursor + 1]);
    }
    return distances;
}
function distanceBetween(pointa, pointb) {
    return EARTH_RADIUS * Math.acos(Math.cos(pointa.lng * Math.PI / 180 - pointb.lng * Math.PI / 180) * Math.cos(pointa.lat * Math.PI / 180) * Math.cos(pointb.lat * Math.PI / 180) + Math.sin(pointa.lat * Math.PI / 180) * Math.sin(pointb.lat * Math.PI / 180));
}

function getPolygonArea(latlngs) {
    var area = 0;
    var coordinate;
    for (var iLatLng = 0; iLatLng < latlngs.length - 1; iLatLng++) {
        var lastIndex = iLatLng + 1;
        coordinate = new RCoordinate();
        coordinate.fromLatLng(latlngs[iLatLng], '');
        var x1 = coordinate.getX();
        var y1 = coordinate.getY();
        coordinate = new RCoordinate();
        coordinate.fromLatLng(latlngs[lastIndex], '');
        var x2 = coordinate.getX();
        var y2 = coordinate.getY();
        var tmp = (x1 * y2 - y1 * x2);
        area += tmp;
    }
    area = Math.abs(area) * 0.5;
    return area;
}
//Global Variables
METERS_PER_DEGREE = 109801.71;
PIXELS_PER_METER = 3779.52438465144;
EARTH_RADIUS = 6378137;
IMPORTED_CLASSES = new Array();
IMG_SERVER = 'http://mapdb0.365ditu.cn/';
JS_SERVER = '/pub/share/js/map';
XML_SERVER = '';
DEBUG_REQUIRED = true;
SVG_URL = "http://www.w3.org/2000/svg";
function RituCode() {
    var MIN_LAT = 0;
    var MAX_LAT = 90;
    var MIN_LNG = 72;
    var MAX_LNG = 171;
    var METERS_PER_DEGREE = 109801.71;
    var originLng = 72;
    var originLat = 0;
    var grid10w = 72;
    var grid10h = 72;
    var grid9w = 8;
    var grid9h = 8;
    var PRECISION = 1000000;
    var grid9Lng = parseInt(grid9w * PRECISION / METERS_PER_DEGREE) / PRECISION;
    var grid9Lat = parseInt(grid9h * PRECISION / METERS_PER_DEGREE) / PRECISION;

    this.isValidLatitude = function(lat) {
        if (lat >= MIN_LAT && lat <= MAX_LAT) {
            return true;
        }

        return false;
    }

    this.isValidLongitude = function(lng) {
        if (lng >= MIN_LNG && lng <= MAX_LNG) {
            return true;
        }

        return false;
    }

    this.encode = function(lat, lng) {
        return this.encodeToNBit(lat, lng, 12);
    }

    this.encodeToNBit = function(lat, lng, codeLength) {
        if (!this.isValidLatitude(lat) || !this.isValidLongitude(lng) || codeLength <= 3 || codeLength % 2 > 0) {
            return '';
        }

        var code = '';
        var latPrecision = Math.floor(codeLength / 2);
        var lngPrecision = codeLength - latPrecision;
        var latOffset = Math.floor((lat - originLat) * Math.pow(10, latPrecision - 2));
        var lngOffset = Math.floor((lng - originLng) * Math.pow(10, lngPrecision - 2));
        var modLng = Math.floor(lngOffset % 99);
        var modLat = Math.floor(latOffset % 99);

        if (modLng < 10) {
            code = '0' + modLng + code;
        }
        else {
            code = '' + modLng + code;
        }

        if (modLat < 10) {
            code = '0' + modLat + code;
        }
        else {
            code = '' + modLat + code;
        }

        lngOffset = Math.floor(lngOffset / 99);
        latOffset = Math.floor(latOffset / 99);

        for (var i = 1; i <= latPrecision - 2; i++) {
            code = Math.floor(lngOffset % 10) + code;
            code = Math.floor(latOffset % 10) + code;
            lngOffset = Math.floor(lngOffset / 10);
            latOffset = Math.floor(latOffset / 10);
        }

        return code;
    }

    this.decode = function(paraRitucode) {
        if (!paraRitucode || paraRitucode.length != 12) {
            return [-1, -1, -1, -1];
        }

        var lngOffset = 0.0;
        var latOffset = 0.0;
        var loopEnd = paraRitucode.length - 4;

        for (var i = 0; i < loopEnd; i += 2) {
            latOffset *= 10;
            latOffset += parseInt(paraRitucode.substr(i, 1), 10);
            lngOffset *= 10;
            lngOffset += parseInt(paraRitucode.substr(i + 1, 1), 10);
        }

        latOffset *= 99;
        latOffset += parseInt(paraRitucode.substr(paraRitucode.length - 4, 2), 10);
        var latPrecision = 1 / Math.pow(10, paraRitucode.length / 2 - 2);
        var lat = latOffset * latPrecision;
        lngOffset *= 99;
        lngOffset += parseInt(paraRitucode.substr(paraRitucode.length - 2, 2), 10);
        var lngPrecision = 1 / Math.pow(10, paraRitucode.length / 2 - 2);
        var lng = lngOffset * lngPrecision + 72;

        if (this.isValidLatitude(lat) && this.isValidLongitude(lng)) {
            var maxLng = lng + lngPrecision;
            maxLng = maxLng > 180 ? 180 : maxLng;
            var maxLat = lat + latPrecision;
            maxLat = maxLat > 90 ? 90 : maxLat;

            return [lng.toFixed(paraRitucode.length / 2 - 2),
                lat.toFixed(paraRitucode.length / 2 - 2),
                maxLng.toFixed(paraRitucode.length / 2 - 2),
                maxLat.toFixed(paraRitucode.length / 2 - 2)];
        }

        return [-1, -1, -1, -1];
    }
}
function enCode(gpsid) {
    var latlng = gpsid;
    var obj = new Array();
    var gpsidCode = new RituCode();
    return gpsidCode.decode(latlng);
}

function code() {
    try {
        var lat = document.getElementById("inputLat").value;
        var lng = document.getElementById("inputLng").value;
        var gpsidCode = new RituCode();
        var latlng = gpsidCode.encode(lat, lng);
        document.getElementById("code").innerHTML = latlng;
    } catch (e) {
        alert("出错");
    }
}